Hello
I search a script to create an new VM. I have an existing vhdx on the VMM-Server. Does anyone has a example.
Many thanks.
Miller
Technology Tips and News
Hello
I search a script to create an new VM. I have an existing vhdx on the VMM-Server. Does anyone has a example.
Many thanks.
Miller
Help new-VM -full
New-Vm ... -VHDPath <existing vhd file> ....
help New-SCVirtualMachine
New-SCVirtualMachine .... -VirtualHardDisk<StandaloneVirtualHardDisk> ...
$servername = "00SRTESTVM" $RAMSize = 2048 $VHDXSize = 80GB $VMLocation = "\\srhost12\c$\ClusterStorage\hyperv16\" $NetworkSwitch1 = "UCS-Switch01" $LibPath = "\\SrSCVMM2.joe.local\MSSCVMMLibrary2\VHDs\Win2012R2" $network = "Server Network VLAN19" $installlocation="D:\MSSCVMMLibrary\VHDs\Win2012R2\" $templatelocation=$installlocation+"VM2012R2Dynamic_disk_C.vhdx" $vmdir=$vmlocation+$servername md "$vmdir" | Out-Null $vmdiskname=$servername+"_c.vhdx" $vmdisk=$vmdir+"\"+$vmdiskname Write-Host Copying Template VHDX copy "$templatelocation" "$vmdisk" Write-Host Mounting VHDX Mount-VHD -Path "$vmdisk" New-SCVirtualMachine -Name $servername -Generation 2 -MemoryMB $RAMSize -Path "$vmlocation" -VirtualHardDisk "$vmdiskname" -SwitchName "$NetworkSwitch1"
I have following error:
New-SCVirtualMachine : Cannot bind parameter 'VirtualHardDisk'. Cannot convert the "00SRTESTVM_c.vhdx" value of type "System.String" to type
"Microsoft.SystemCenter.VirtualMachineManager.StandaloneVirtualHardDisk".
At line:1 char:110
+ ... irtualHardDisk "$vmdiskname" -SwitchName "$NetworkSwitch1"
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-SCVirtualMachine], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.NewVmCmdlet
How can I fix that Problem?
thanks. miller