We had an issue with a NIC card dropping down to <100 mbit over night and our VM exports (backups) did not complete which caused an issue when everyone got in today as one of our VMs was still down and exporting.
The issue was a faulty cable and is resolved, but we want to extend our powershell scripts so we can cancel a currently exporting vm if this happens again. Obviously this is possible as I can cancel the job from the Hyper-V manager.
I can get the GUID "InstanceID" of the job when I run Export-VM, but I can also see it when I look at the the properties of the job when I call:
where $vm is one of our VMs.
However, even though I have the InstanceID, when I call Stop-Job or Remove-Job I get an error that the job does not exist. Test-WMIJob returns successfully with the supplied Job object.
Furthermore, if I run a simple asynchronous Export-VM command (outside my script) and then run Get-Job it returns nothing (if run with no parameters it should return all jobs in the session).
Is all this because the job is a WMI Job? If so is there another way to cancel the job via powershell?
Any help would be appreciated.