1

DDCTK-H SCVMM 2012 サンプルをダウンロードし、SCVMM 2012 の全機能を使用するために wcf プロジェクトを少し変更しました。

私の目的は、既存の vhd から vm を作成することです。現在、vm を作成できますが、ハードディスクを使用して vm を作成することはできません。現在、既存の vhd を使用することをあきらめ、空の IDE ハードディスクで vm を作成したいと考えています。

SCVMM 2012 の Virtual Manager Console で、既存のスタンドアロン vhd を使用して vm を作成しようとしました。これにはウィザードがあり、最後に [View Scripts] をクリックすると、このジョブに必要なすべてのスクリプトを表示できます。

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 スクリプトを使用すると、空のハード ディスクで vm を作成できます。それは今私にとってクールです。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 を作成します。ただし、ディスクは接続されていません。私には何かが欠けているように思えます。New-SCVirtualDiskDriveコマンドレットのドキュメントによると、仮想ハード ドライブを作成し、戻り値として、作成されたディスク オブジェクト (VirtualDiskDrive のインスタンス) を返します。正常に実行されても、値は返されません。

ちなみに、次のコードの ps スクリプト バージョンも使用しようとしましたが、うまくいきました。空のハード ディスクを持つ新しい vm が作成されます。

したがって、New-SCVirtualDiskDrive コマンドレットには問題があります。この問題を解決するには?助けていただけますか?

4

1 に答える 1

0

ライブラリ サーバーから既存の VHD を使用して VM を作成するための [スクリプトの表示] オプションからは、次のようになります。

New-SCVirtualDiskDrive -VMMServer $FQDNName -IDE -Bus 0 -LUN 0 -JobGroup $virtualDiskguid -CreateDiffDisk $false -virtualHardDisk $virtualHardDisk -VolumeType BootAndSystem -Verbose

ここで$JobGroup、ステップのグループが一緒に実行されるときに生成される uniqueID です。

于 2015-05-06T17:58:25.463 に答える