Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# create a directory for virtual machines
PS C:\Users\Administrator> mkdir C:\Virtual_Machine
# confirm virtual switches
PS C:\Users\Administrator> Get-VMSwitch
Name SwitchType NetAdapterInterfaceDescription
---- ---------- ------------------------------
Bridge01 External Intel(R) 82574L Gigabit Network Connection
# set virtual machine name and others
PS C:\Users\Administrator> $ParentDir = 'C:\Virtual_Machine'
PS C:\Users\Administrator> $VMName = 'Win2k22'
PS C:\Users\Administrator> $Switch = 'Bridge01'
# create a virtual machine
PS C:\Users\Administrator> New-VM -Name $VMName `
-MemoryStartupBytes 8GB `
-Generation 1 `
-NewVHDPath "$ParentDir\$VMName\$VMName.vhdx" `
-NewVHDSizeBytes 50GB `
-Path "$ParentDir\$VMName" `
-SwitchName $Switch
Name State CPUUsage(%) MemoryAssigned(M) Uptime Status Version
---- ----- ----------- ----------------- ------ ------ -------
Win2k22 Off 0 0 00:00:00 Operating normally 10.0
# change vCPU count
PS C:\Users\Administrator> Set-VMProcessor $VMName -Count 4
# add SCSI controler
PS C:\Users\Administrator> Add-VMScsiController -VMName $VMName
# set install image
PS C:\Users\Administrator> Add-VMDvdDrive -VMName $VMName `
-ControllerNumber 1 `
-ControllerLocation 0 `
-Path 'C:\Users\Administrator\Documents\Win2022_EN-US_20348.169.210806-2348.fe.iso'
# set virtual DVD first boot device
PS C:\Users\Administrator> Set-VMFirmware -VMName $VMName -FirstBootDevice (Get-VMDvdDrive -VMName $VMName)
# start the virtual machine
PS C:\Users\Administrator> Start-VM -Name $VMName
# after this, refer to [13] to install OS
|