PowerShell/docs/new-windows-vm.md
2024-05-19 10:25:56 +02:00

928 B

Script: new-windows-vm.ps1

new-windows-vm.ps1

Parameters



[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

Script Content

$VMName = "windows"

 $VM = @{
     Name = $VMName
     MemoryStartupBytes = 4GB
     Generation = 2
     NewVHDPath = "C:\VirtualMachines\$VMName\Virtual Hard Disks\$VMName.vhdx"
     NewVHDSizeBytes = 50GB
     BootDevice = "VHD"
     Path = "C:\VirtualMachines\"
     SwitchName = 'vSwitch'
 }

 New-VM @VM
 Set-VMProcessor $VMName -count 1
 Add-VMDvdDrive $VMName
 Set-VMDvdDrive $VMName -Path "C:\iso\Win10_21H1_English_x64.iso"
exit 0 # success

(generated by convert-ps2md.ps1 using the comment-based help of new-windows-vm.ps1 as of 05/19/2024 10:25:23)