Reading the mouse position of a Hyper-V VM

Last week I showed you how to automate setting the mouse position in a virtual machine.  You can also read the current position of the mouse cursor using this code:

$VMName = "Windows 10 Enterprise"
$VMCS = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter "ElementName='$($VMName)'"
$mouse = $VMCS.GetRelated("Msvm_SyntheticMouse")
$mouse.HorizontalPosition
$mouse.VerticalPosition

Cheers,
Ben