diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 1336190..6d1672c 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -22,10 +22,34 @@
 #include <utils/json_utils.hpp>
 // for GetObjectType and ManagedObjectType
 #include <account_service.hpp>
+#include <boost/url/url_view.hpp>
 
 namespace redfish
 
 {
+/**
+ * @brief Function extracts transfer protocol name from URI.
+ */
+static std::string getTransferProtocolTypeFromUri(const std::string& imageUri)
+{
+    try
+    {
+        std::string_view scheme = boost::urls::url_view(imageUri).scheme();
+        if (scheme == "smb")
+        {
+            return "CIFS";
+        }
+        else if (scheme == "https")
+        {
+            return "HTTPS";
+        }
+    }
+    catch (std::exception& p)
+    {
+        BMCWEB_LOG_ERROR << p.what();
+    }
+    return "None";
+}
 
 /**
  * @brief Read all known properties from VM object interfaces
@@ -89,31 +113,46 @@
         else
         {
             // Legacy mode
-            const auto imageUrlProperty =
-                mountPointIface->second.find("ImageURL");
-            if (imageUrlProperty != processIface->second.cend())
+            for (const auto& property : mountPointIface->second)
             {
-                const std::string* imageUrlValue =
-                    std::get_if<std::string>(&imageUrlProperty->second);
-                if (imageUrlValue && !imageUrlValue->empty())
+                if (property.first == "ImageURL")
                 {
-                    std::filesystem::path filePath = *imageUrlValue;
-                    if (!filePath.has_filename())
+                    const std::string* imageUrlValue =
+                        std::get_if<std::string>(&property.second);
+                    if (imageUrlValue && !imageUrlValue->empty())
                     {
-                        // this will handle https share, which not necessarily
-                        // has to have filename given.
-                        aResp->res.jsonValue["ImageName"] = "";
-                    }
-                    else
-                    {
-                        aResp->res.jsonValue["ImageName"] = filePath.filename();
-                    }
+                        std::filesystem::path filePath = *imageUrlValue;
+                        if (!filePath.has_filename())
+                        {
+                            // this will handle https share, which not
+                            // necessarily has to have filename given.
+                            aResp->res.jsonValue["ImageName"] = "";
+                        }
+                        else
+                        {
+                            aResp->res.jsonValue["ImageName"] =
+                                filePath.filename();
+                        }
 
-                    aResp->res.jsonValue["Image"] = *imageUrlValue;
-                    aResp->res.jsonValue["Inserted"] = *activeValue;
-                    if (*activeValue == true)
+                        aResp->res.jsonValue["Image"] = *imageUrlValue;
+                        aResp->res.jsonValue["Inserted"] = *activeValue;
+                        aResp->res.jsonValue["TransferProtocolType"] =
+                            getTransferProtocolTypeFromUri(*imageUrlValue);
+
+                        if (*activeValue == true)
+                        {
+                            aResp->res.jsonValue["ConnectedVia"] = "URI";
+                        }
+                    }
+                }
+                else if (property.first == "WriteProtected")
+                {
+                    const bool* writeProtectedValue =
+                        std::get_if<bool>(&property.second);
+                    if (writeProtectedValue)
                     {
-                        aResp->res.jsonValue["ConnectedVia"] = "URI";
+                        aResp->res.jsonValue["WriteProtected"] =
+                            *writeProtectedValue;
                     }
                 }
             }
@@ -288,22 +327,28 @@
     std::optional<TransferProtocol>
         getTransferProtocolFromUri(const std::string& imageUri)
     {
-        if (imageUri.find("smb://") != std::string::npos)
+        try
         {
-            return TransferProtocol::smb;
+            std::string_view scheme = boost::urls::url_view(imageUri).scheme();
+            if (scheme == "smb")
+            {
+                return TransferProtocol::smb;
+            }
+            else if (scheme == "https")
+            {
+                return TransferProtocol::https;
+            }
+            else if (!scheme.empty())
+            {
+                return TransferProtocol::invalid;
+            }
         }
-        else if (imageUri.find("https://") != std::string::npos)
+        catch (std::exception& p)
         {
-            return TransferProtocol::https;
+            BMCWEB_LOG_ERROR << p.what();
         }
-        else if (imageUri.find("://") != std::string::npos)
-        {
-            return TransferProtocol::invalid;
-        }
-        else
-        {
-            return {};
-        }
+
+        return {};
     }
 
     /**
