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 = 'CentOS Stream 9'
PS C:\Users\Administrator> $Switch = 'Bridge01'
# create a virtual machine
PS C:\Users\Administrator> New-VM -Name $VMName `
-MemoryStartupBytes 4GB `
-Generation 1 `
-NewVHDPath "$ParentDir\$VMName\$VMName.vhdx" `
-NewVHDSizeBytes 20GB `
-Path "$ParentDir\$VMName" `
-SwitchName $Switch
Name State CPUUsage(%) MemoryAssigned(M) Uptime Status Version
---- ----- ----------- ----------------- ------ ------ -------
CentOS Stream 9 Off 0 0 00:00:00 Operating normally 10.0
# change vCPU count
PS C:\Users\Administrator> Set-VMProcessor $VMName -Count 2
# onfirm virtual DVD drive
PS C:\Users\Administrator> Get-VMDvdDrive -VMName $VMName
VMName ControllerType ControllerNumber ControllerLocation DvdMediaType Path
------ -------------- ---------------- ------------------ ------------ ----
CentOS Stream 9 IDE 1 0 None
# set install image to virtual DVD drive
PS C:\Users\Administrator> Set-VMDvdDrive -VMName $VMName `
-Path 'C:\Users\Administrator\Documents\CentOS-Stream-9-latest-x86_64-dvd1.iso'
PS C:\Users\Administrator> Get-VMDvdDrive -VMName $VMName
VMName ControllerType ControllerNumber ControllerLocation DvdMediaType Path
------ -------------- ---------------- ------------------ ------------ ----
CentOS Stream 9 IDE 1 0 ISO C:\Users\Administrator\Documents\CentOS-Stre...
# start the virtual machine
PS C:\Users\Administrator> Start-VM -Name $VMName
# after this, refer to [13] to install OS
|