Skip to content

Instantly share code, notes, and snippets.

View AlexJamesHaines's full-sized avatar

Alex 'Freedom' Haines AlexJamesHaines

View GitHub Profile
@AlexJamesHaines
AlexJamesHaines / SaveVMBitmap.ps1
Created April 27, 2022 19:32 — forked from BenjaminArmstrong/SaveVMBitmap.ps1
Sample PowerShell script that shows you how to create a .BMP file of the display of a Hyper-V virtual machine.
$VMName = "VM 1"
$BMPName = "C:\Users\benja\Desktop\test.bmp"
Add-Type -AssemblyName "System.Drawing"
$VMCS = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter "ElementName='$($VMName)'"
# Get the resolution of the screen at the moment
$video = $VMCS.GetRelated("Msvm_VideoHead")
$xResolution = $video.CurrentHorizontalResolution[0]