Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Hyper‐V Creating New, and Linked VM's

From Thibble Wiki
Revision as of 02:22, 2 November 2024 by T20A02 (talk | contribs) (Created page with "== Creating a Base VM in Hyper-V with Windows Server 2019 == === Creating the Base VM === ==== PowerShell Commands: ==== These are the commands used in order top create a new base VM via powershell <pre> $VMName = "BaseVM" $VMPath = "C:\Hyper-V\VMs" $ISOPath = "C:\Path\to\WindowsServer2019.iso" New-VM -Name $VMName -Path $VMPath -MemoryStartupBytes 4GB -NewVHDPath "$VMPath\$VMName.vhdx" -NewVHDSizeBytes 60GB Set-VMBios -VMName $VMName -BootOrder "CD" Add-VMDvdDrive...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Creating a Base VM in Hyper-V with Windows Server 2019

Creating the Base VM

PowerShell Commands:

These are the commands used in order top create a new base VM via powershell

$VMName = "BaseVM"
$VMPath = "C:\Hyper-V\VMs"
$ISOPath = "C:\Path\to\WindowsServer2019.iso"

New-VM -Name $VMName -Path $VMPath -MemoryStartupBytes 4GB -NewVHDPath "$VMPath\$VMName.vhdx" -NewVHDSizeBytes 60GB
Set-VMBios -VMName $VMName -BootOrder "CD"
Add-VMDvdDrive -VMName $VMName -Path $ISOPath
Start-VM -Name $VMName

These are the commands used in order, to make a linked clone of a VM

$LinkedVMName = "LinkedCloneVM"

New-VHD -Path "C:\Hyper-V\VMs\$LinkedVMName.vhdx" -ParentPath "C:\Hyper-V\VMs\BaseVM.vhdx" -Differencing
New-VM -Name $LinkedVMName -Path "C:\Hyper-V\VMs" -MemoryStartupBytes 4GB -VHDPath "C:\Hyper-V\VMs\$LinkedVMName.vhdx"
Start-VM -Name $LinkedVMName

Other General Commands:

  1. Interacting with PowerShell Commands

To stop a virtual machine using PowerShell, you can execute the following command:

Stop-Service -Name YourVMName
# OR
Stop-Process -Name YourVMName


Checkpoint-VM -Name YourVMName -SnapshotName snapshot1
# OR
Checkpoint-Computer -Name YourVMName -SnapshotName snapshot1


Start-Service -Name YourVMName
# OR
Start-Process -Name YourVMName


# Change the network profile for 'YourVMName' to another network by name
Set-NetConnectionProfile -InterfaceAlias YourVMName -NetworkCategory "Private"

# OR

# Change the IP address of 'YourVMName' to another network
Set-NetIPAddress -InterfaceAlias YourVMName -IPAddress NewIPAddress -PrefixLength SubnetMask -DefaultGateway NewGateway

Written in part with ChatGPT