Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用SCVMM Powershell cmdlet:新的SCVirtualDiskDrive用法_Powershell_Hyper V - Fatal编程技术网

使用SCVMM Powershell cmdlet:新的SCVirtualDiskDrive用法

使用SCVMM Powershell cmdlet:新的SCVirtualDiskDrive用法,powershell,hyper-v,Powershell,Hyper V,为了使用SCVMM 2012的全部功能,我下载并修改了一点wcf项目 我的目的是从现有vhd创建vm。现在我可以创建一个虚拟机,但我就是不能成功地创建一个带有硬盘的虚拟机。现在我放弃了用现有的vhd来做这件事,而是想用空的IDE硬盘来创建一个vm 我尝试在SCVMM 2012的Virtual Manager控制台上使用现有的独立vhd创建vm。这有一个向导,最后单击“查看脚本”,您可以看到此作业所需的所有脚本 New-SCVirtualScsiAdapter -VMMServer localho

为了使用SCVMM 2012的全部功能,我下载并修改了一点wcf项目

我的目的是从现有vhd创建vm。现在我可以创建一个虚拟机,但我就是不能成功地创建一个带有硬盘的虚拟机。现在我放弃了用现有的vhd来做这件事,而是想用空的IDE硬盘来创建一个vm

我尝试在SCVMM 2012的Virtual Manager控制台上使用现有的独立vhd创建vm。这有一个向导,最后单击“查看脚本”,您可以看到此作业所需的所有脚本

New-SCVirtualScsiAdapter -VMMServer localhost -JobGroup 10a46201-6b94-493f-b402-1e2b46911580 -AdapterID 7 -ShareVirtualScsiAdapter $false -ScsiControllerType DefaultTypeNoType 

New-SCVirtualDVDDrive -VMMServer localhost -JobGroup 10a46201-6b94-493f-b402-1e2b46911580 -Bus 1 -LUN 0 

New-SCVirtualNetworkAdapter -VMMServer localhost -JobGroup 10a46201-6b94-493f-b402-1e2b46911580 -MACAddressType Dynamic -Synthetic -EnableVMNetworkOptimization $false 

Set-SCVirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 1 -JobGroup 10a46201-6b94-493f-b402-1e2b46911580 

Set-SCVirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 2 -JobGroup 10a46201-6b94-493f-b402-1e2b46911580 

Set-SCVirtualFloppyDrive -RunAsynchronously -VMMServer localhost -NoMedia -JobGroup 10a46201-6b94-493f-b402-1e2b46911580 

$CPUType = Get-SCCPUType -VMMServer localhost | where {$_.Name -eq "3.60 GHz Xeon (2 MB L2 cache)"}

New-SCHardwareProfile -VMMServer localhost -CPUType $CPUType -Name "Profile865cc017-4009-4ab3-9b58-0210f1d70daa" -Description "Profile used to create a VM/Template" -CPUCount 1 -MemoryMB 512 -DynamicMemoryEnabled $false -MemoryWeight 5000 -VirtualVideoAdapterEnabled $false -CPUExpectedUtilizationPercent 20 -DiskIops 0 -CPUMaximumPercent 100 -CPUReserve 0 -NumaIsolationRequired $false -NetworkUtilizationMbps 0 -CPURelativeWeight 100 -HighlyAvailable $false -DRProtectionRequired $false -NumLock $false -BootOrder "CD", "IdeHardDrive", "PxeBoot", "Floppy" -CPULimitFunctionality $false -CPULimitForMigration $false -JobGroup 10a46201-6b94-493f-b402-1e2b46911580 

New-SCVirtualDiskDrive -VMMServer localhost -IDE -Bus 0 -LUN 0 -JobGroup 10a46201-6b94-493f-b402-1e2b46911580 -VirtualHardDiskSizeMB 40960 -Dynamic -Filename "aaa_disk_1" -VolumeType BootAndSystem 

$HardwareProfile = Get-SCHardwareProfile -VMMServer localhost | where {$_.Name -eq "Profile865cc017-4009-4ab3-9b58-0210f1d70daa"}

New-SCVMTemplate -Name "Temporary Template94a74fb9-9cab-4e22-b653-91c5778732cb" -HardwareProfile $HardwareProfile -JobGroup 10a46201-6b94-493f-b402-1e2b46911580 -NoCustomization 

$template = Get-SCVMTemplate -All | where { $_.Name -eq "Temporary Template94a74fb9-9cab-4e22-b653-91c5778732cb" }
$virtualMachineConfiguration = New-SCVMConfiguration -VMTemplate $template -Name "aaa"
Write-Output $virtualMachineConfiguration
$cloud = Get-SCCloud -Name "MyVMCloud"
New-SCVirtualMachine -Name "aaa" -VMConfiguration $virtualMachineConfiguration -Cloud     $cloud -Description "bbb" -JobGroup "10a46201-6b94-493f-b402-1e2b46911580" -ReturnImmediately -StartAction "NeverAutoTurnOnVM" -StopAction "SaveVM"
有了这些ps脚本,我可以创建一个有空硬盘的虚拟机;现在对我来说很酷。因此,我试图简化脚本,因为我不想在DDCTK-H示例中实现SCVMM 2012的全部功能

public interface IManagementService
{
    VirtualDiskDriveInfo NewVirtualDiskDriveFromAnyHostDiskToJobGroup(string scvmmServerName, int port, bool anyStorageDisk, byte bus, VHDBusTypeInfo busType, byte lun, Guid jobGroup, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromAnyHostDiskToTemplate(string scvmmServerName, int port, bool anyStorageDisk, byte bus, VHDBusTypeInfo busType, byte lun, Guid VMTemplateID, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromExistingHostVHDToVM(string scvmmServerName, int port, byte bus, VHDBusTypeInfo busType, byte lun, string fileName, string path, bool useLocalVirtualHardDisk, Guid vmID, Guid jobGroup = default(Guid), bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromExistingVHDToJobGroup(string scvmmServerName, int port, byte bus, VHDBusTypeInfo busType, byte lun, Guid virtualHardDiskID, Guid jobGroup, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromExistingVHDToTemplate(string scvmmServerName, int port, byte bus, VHDBusTypeInfo busType, byte lun, Guid virtualHardDiskID, Guid vmTemplateID, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromExistingVHDToVM(string scvmmServerName, int port, byte bus, VHDBusTypeInfo busType, byte lun, Guid virtualHardDiskID, Guid vmID, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromHostDiskToJobGroup(string scvmmServerName, int port, byte bus, VHDBusTypeInfo busType, byte lun, Guid jobGroup, Guid storageDiskID, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromHostDiskToVM(string scvmmServerName, int port, byte bus, VHDBusTypeInfo busType, byte lun, Guid storageDiskID, Guid vmID, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromNewToJobGroup(string scvmmServerName, int port, byte bus, VHDBusTypeInfo busType, byte lun, string fileName, Guid jobGroup, long virtualHardDiskSizeMB, bool isFixed = false, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromNewToTemplate(string scvmmServerName, int port, byte bus, VHDBusTypeInfo busType, byte lun, string fileName, long virtualHardDiskSizeMB, Guid vmTemplateID, bool isFixed = false, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);
    VirtualDiskDriveInfo NewVirtualDiskDriveFromNewToVM(string scvmmServerName, int port, byte bus, VHDBusTypeInfo busType, byte lun, string fileName, long virtualHardDiskSizeMB, Guid vmID, bool isFixed = false, bool bootVolume = false, string jobVariable = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid storageClassificationID = default(Guid), bool systemVolume = false, VolumeTypeInfo volumeType = VolumeTypeInfo.None);

    //many more methods goes here...

    VMInfo NewStoredVirtualMachineFromHardwareProfile(string scvmmServerName, int port, string name, Guid libraryServerID, string sharePath = null, byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, Guid hardwareProfileID = default(Guid), Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string owner = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, VMStopActionInfo? stopAction = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null);
    VMInfo NewStoredVirtualMachineFromVirtualDisk(string scvmmServerName, int port, string name, Guid libraryServerID, string sharePath = null, Guid virtualHardDiskID = default(Guid), byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, Guid hardwareProfileID = default(Guid), Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string owner = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, VMStopActionInfo? stopAction = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null);
    VMInfo NewStoredVirtualMachineFromVirtualMachine(string scvmmServerName, int port, string name, Guid libraryServerID, string sharePath = null, Guid vmID = default(Guid), byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, Guid hardwareProfileID = default(Guid), Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string owner = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, VMStopActionInfo? stopAction = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null);
    VMInfo NewVirtualMachineFromComputerTierScaleOut(string scvmmServerName, int port, string name, Guid computerTierID, string computerName = null, byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, Guid hardwareProfileID = default(Guid), Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string owner = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, VMStopActionInfo? stopAction = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null);
    VMInfo NewVirtualMachineFromHardwareProfile(string scvmmServerName, int port, string name, string path, Guid vmHostID, bool blockDynamicOptimization = false, byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, Guid hardwareProfileID = default(Guid), bool? highlyAvailable = null, Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string owner = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, bool startVM = false, VMStopActionInfo? stopAction = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null);
    VMInfo NewVirtualMachineFromTemplate(string scvmmServerName, int port, string name, string path, Guid vmHostID, Guid vmTemplateID, Guid answerFileID, bool blockDynamicOptimization = false, string computerName = null, byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, string domain = null, /*Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.VMMCredential*/object domainJoinCredential = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, string fullName = null, /*Microsoft.SystemCenter.VirtualMachineManager.GuestOSProfile*/object guestOSProfile = null, string[] guiRunOnceCommands = null, Guid hardwareProfileID = default(Guid), bool? highlyAvailable = null, Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, bool? mergeAnswerFile = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string organizationName = null, string owner = null, string productKey = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, bool startVM = false, VMStopActionInfo? stopAction = null, int? timeZone = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null, string workgroup = null);
    VMInfo NewVirtualMachineFromVirtualDisk(string scvmmServerName, int port, string name, string path, Guid virtualHardDiskID, Guid vmHostID, bool? blockDynamicOptimization = null, byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, Guid hardwareProfileID = default(Guid), bool? highlyAvailable = null, Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string owner = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, bool startVM = false, VMStopActionInfo? stopAction = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null);
    VMInfo NewVirtualMachineFromVirtualMachine(string scvmmServerName, int port, string name, string path, Guid vmID, Guid vmHostID, byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, Guid hardwareProfileID = default(Guid), bool? highlyAvailable = null, Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string owner = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, bool startVM = false, VMStopActionInfo? stopAction = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null);
    VMInfo NewVirtualMachineFromVirtualMachineCloud(string scvmmServerName, int port, string name, Guid cloudID, Guid vmID, Guid capabilityProfile = default(Guid), byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, Guid hardwareProfileID = default(Guid), bool? highlyAvailable = null, Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string owner = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid selfServiceUserRole = default(Guid), bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, bool startVM = false, VMStopActionInfo? stopAction = null, bool storeToLibrary = false, int? timeZone = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null, string workgroup = null);
    VMInfo NewVirtualMachineFromVirtualMachineConfiguration(string scvmmServerName, int port, string name, Guid vmConfigurationID, Guid answerFileID, bool? blockDynamicOptimization = null, Guid capabilityProfileID = default(Guid), Guid cloudID = default(Guid), string computerName = null, byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, string domain = null, /*Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.VMMCredential*/object domainJoinCredential = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, string fullName = null, /*Microsoft.SystemCenter.VirtualMachineManager.GuestOSProfile*/object guestOSProfile = null, string[] guiRunOnceCommands = null, Guid hardwareProfileID = default(Guid), Guid jobGroup = default(Guid), string jobVariable = null, /*Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.VMMCredential*/object localAdministratorCredential = null, ushort? memoryMB = null, ushort? memoryWeight = null, bool? mergeAnswerFile = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string organizationName = null, string owner = null, string productKey = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, Guid selfServiceRoleID = default(Guid), bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, bool startVM = false, VMStopActionInfo? stopAction = null, bool storeToLibrary = false, int? timeZone = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null, string workgroup = null);
    VMInfo NewVirtualMachineFromVirtualMachineConfigurationScaleOut(string scvmmServerName, int port, string name, Guid vmConfigurationScaleOutID, byte? cpuCount = null, bool? cpuLimitForMigration = null, bool? cpuLimitFuntionality = null, ushort? cpuRelativeWeight = null, Guid cpuTypeID = default(Guid), ushort? delayStartSeconds = null, string description = null, ushort? dynamicMemoryBufferPercentage = null, bool? dynamicMemoryEnabled = null, ushort? dynamicMemoryMaximumMB = null, Guid hardwareProfileID = default(Guid), bool? highlyAvailable = null, Guid jobGroup = default(Guid), string jobVariable = null, ushort? memoryMB = null, ushort? memoryWeight = null, ushort? monitorMaximumCount = null, string monitorMaximumResolution = null, Guid operatingSystemID = default(Guid), string owner = null, Guid proTipID = default(Guid), bool returnImmediately = false, bool runAsynchronously = false, bool skipInstallVirtualizationGuestServices = false, VMStartActionInfo? startAction = null, VMStopActionInfo? stopAction = null, bool useLocalVirtualHardDisk = false, Guid userRoleID = default(Guid), bool? virtualVideoAdapterEnabled = null);
}
我用过这样的服务方式

private void CreateNewVM(ManagementServiceClient service)
{
    using (VMInfoForm vmForm = new VMInfoForm(null))
    {
        DialogResult result = vmForm.ShowDialog(this);
        if (result != System.Windows.Forms.DialogResult.OK)
            return;

        Guid jg = Guid.NewGuid();
        VirtualHardDiskInfo vhdiX = service.GetVirtualHardDiskByName(tbIP.Text, int.Parse(tbPort.Text), "X.vhd");
        VirtualDiskDriveInfo vdd = service.NewVirtualDiskDriveFromNewToJobGroup(tbIP.Text, int.Parse(tbPort.Text), 0, VHDBusTypeInfo.IDE, 0, string.Format("{0}_{1}", vmForm.VMName, "disk"), jg, 40960, volumeType: VolumeTypeInfo.BootAndSystem);
        VMInfo vm = service.NewVirtualMachineFromVirtualDisk(tbIP.Text, int.Parse(tbPort.Text), vmForm.VMName, @"C:\ProgramData\Microsoft\Windows\Hyper-V", vhdiX.ID, host.ID, returnImmediately: false, startAction: VMStartActionInfo.NeverAutoTurnOnVM, stopAction: VMStopActionInfo.SaveVM, jobGroup: jg);
        RefreshVMs(service); // Refresh the listbox of vm's.
    }
}
这段代码成功地创建了一个vm;但是,没有磁盘连接到它。在我看来,我好像错过了什么。根据cmdlet的文档,它创建一个虚拟硬盘驱动器,并作为返回值返回创建的磁盘对象(VirtualDiskDrive的实例)。即使它成功执行,也不会返回任何值

顺便说一句,我还尝试使用以下代码的ps脚本版本,它成功了:创建了一个带有空硬盘的新vm


因此,新的SCVirtualDiskDrive cmdlet存在问题。如何解决这个问题?您能提供帮助吗?

从“查看脚本”选项中,使用库服务器中的现有VHD创建VM的步骤如下:

New-SCVirtualDiskDrive -VMMServer $FQDNName -IDE -Bus 0 -LUN 0 -JobGroup $virtualDiskguid -CreateDiffDisk $false -virtualHardDisk $virtualHardDisk -VolumeType BootAndSystem -Verbose
其中,
$JobGroup
是在一起执行一组步骤时生成的唯一ID