Beispiel #1
0
        internal static void SetVhd(this ManagementScope scope, string vmIdentity, string vhdFilepath)
        {
            var virtualMachine           = scope.GetVirtualMachine(vmIdentity);
            var virtualSystemSettingData = virtualMachine.GetVirtualSystemSettingData();

            var diskDriveResource = scope.GetDiscDriveResource(virtualSystemSettingData);

            var allocationSettingData = scope.GetAllocationSettingDataForVirtualHardDisks();

            allocationSettingData["Parent"]       = diskDriveResource;
            allocationSettingData["HostResource"] = new string[] { vhdFilepath };

            scope.AddResourceSettings(virtualSystemSettingData, allocationSettingData);
        }