How to setup and manage Hyper-V Virtual Machines from Powershell remotely

Steps to create and manage Hyper-V virtual machines in Powershell:

  1. Create a new Virtual Hard Drive Disk with following command
    1. "New-VHD -Path "[Path to Virtual Machines Directory]" -SizeBytes [Big enough to hold and manage data] GB -Dynamic
  2. Create the new VM using the following command
    1. "New-VM -Name "[Name of Machine]" -MemoryStartupBytes [reasonable size]GB -Generation 2 -VHDPath [Path from Step 1] -SwitchName "[VM Switch]" "
  3. Set # of processor cores for VM with the following command
    1. "Set-VMProcessor -VMName "[Name of VM]" -Count [Desired # of processor cores]
  4. Manage machine memory with the following:
    1. "Set-VMMemory -VMName "[Name of VM]" -StartupBytes [New Size]GB
  5. Set checkpoints to OFF with the following:
    1. "Set-VM -Name "[Name of VM]" -CheckpointType Disabled "
  6. Add an OS ISO to Virtual Machine using following command
    1. Add-VMDVDDrive -VMName -Path Copya068d633a447.png