new-scvirtualmachine with existing patched vhdx

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

July 4th, 2015 9:16am

Help new-VM -full

New-Vm ... -VHDPath <existing vhd file> ....

July 4th, 2015 10:12am

it's not a local Hyper-V System -> it's a VMM and there are some parts like virtualadapter, hardwareprofile....
Free Windows Admin Tool Kit Click here and download it now
July 4th, 2015 11:25am

help New-SCVirtualMachine

New-SCVirtualMachine .... -VirtualHardDisk<StandaloneVirtualHardDisk> ...

July 4th, 2015 12:10pm

$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

Free Windows Admin Tool Kit Click here and download it now
July 4th, 2015 3:13pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics