Powershell manipulate VM

Manipulate virtual machines using powershell

# find the vm
$query = "SELECT * FROM Msvm_ComputerSystem WHERE ElementName='" + $VMName + "'"
# get the vm
$vm = get-wmiobject -query $query -namespace "root\virtualization" -computername "."
 
# turn the vm on 
$res = $vm.RequestStateChange(2)

# name of the vm we want to start
$vmName = "my-vm"

You may also like...