Hey there!
If you working with Client Management, you probably have some test-pc´s on your machine, Hyper-V machines maybe?
So Ive made a script that creates Hyper-V machines pretty sweet actually.
Let me go through the script here.
1. First, you need to modify the script, Go to the #Modify part of the script, change it so it fits your computer.
2 If you dont know what NetworkSwitch that you uses, you can find it Here
(In my case im using “Bridge”
2. Then save it and run the script.
Param( [Parameter(mandatory=$True,HelpMessage="Whats the name of the VM?")] [ValidateNotNullOrEmpty()] $VM_Name, [parameter(mandatory=$True,HelpMessage="How much memory do you want in GB?(Example 4)")] [ValidateNotNullOrEmpty()] $VMMemoryinGB, [parameter(mandatory=$True,HelpMessage="How large HD in GB (Example 80)")] [ValidateNotNullOrEmpty()] $HDsizeinGB ) Function Select-FolderDialog { param([string]$Description="Select a Folder that you wanna save your vhdx files",[string]$RootFolder="Desktop") [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null $objForm = New-Object System.Windows.Forms.FolderBrowserDialog $objForm.Rootfolder = $RootFolder $objForm.Description = $Description $Show = $objForm.ShowDialog() If ($Show -eq "OK") { Return $objForm.SelectedPath } Else { Write-Error "Operation cancelled by user." } } # You can modify here if you always want to save your machines to a specific folder. $Folderpath = Select-FolderDialog $Path = "$Folderpath\$VM_name.vhdx" #Modify #Change $NetworkSwitch to your standard switch in hyper-v, mine is Bridge $NetworkSwitch = "Bridge" #Creating Virtual machine New-VM -Name "$VM_Name" –MemoryStartupBytes ([int64]$VMMemoryinGB*1024*1024*1024) -NewVHDPath $Path -NewVHDSizeBytes ([int64]$HDsizeinGB*1024*1024*1024) -Generation 2 -SwitchName $NetworkSwitch #Change boot Order 'Network THEN Hardrive' $vmNetworkAdapter = get-VMNetworkAdapter -Name "Network Adapter" -VMName "$VM_Name" $vmHardDiskDrive = get-VMHardDiskDrive -VMName "$VM_Name" Set-VMFirmware "$VM_Name" -BootOrder $vmNetworkAdapter, $vmHardDiskDrive Start-vm $VM_name & vmconnect.exe localhost $VM_name Write-host "Succefully Created VM, Starting.." -ForegroundColor Green
( You can also download the script here New-VM )
3. When you running the script, you gotta answer some questions. (Type !? for help)
4 (Optional) If you want you could just run the script with some parameters like this or you could run the script in the console
5. Answer all of them like this.
6. Then the Machine will start, and you are good to go.
7. Done
Good luck
/Pontus
Spot on with this write-up, I truly think this web site wants far more consideration. I’ll probably be again to learn way more, thanks for that info. http://hellowh983mm.com
LikeLike