Power-V: PowerShell scripts for managing Hyper-V virtual machines
Get-VM | Remove-VMSnapshot | |
$rootedVHDs = (Get-VM).HardDrives.Path | |
Return Get-ChildItem (Get-VMHost).VirtualHardDiskPath | Where-Object { $_.FullName -notin $rootedVHDs } |
Param( | |
$VMName, | |
$MemoryStartupBytes, | |
$NewVHDSizeBytes, | |
$IsoPath | |
) | |
$VM = New-VM $VMName $MemoryStartupBytes 2 -NewVHDPath ($VMName + ".vhdx") -NewVHDSizeBytes $NewVHDSizeBytes -BootDevice VHD -SwitchName External | |
Set-VM $VM -ProcessorCount 2 -MemoryMaximumBytes $MemoryStartupBytes -AutomaticCheckpointsEnabled $false | |
Set-VMFirmware $VM -EnableSecureBoot Off | |
Add-VMDvdDrive $VM -Path $IsoPath | |
Return $VM |
Param( | |
$VMName | |
) | |
$vm = Get-VM $VMName | |
Get-VMSnapshot $vm | Remove-VMSnapshot | |
$vhds = $vm.HardDrives.Path | |
Remove-VM $vm -Force | |
Remove-Item $vhds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment