Hyper-V CimSession Caching Bug
The Server 2016 Hyper-V module caches CimSessions, presumably to make queries for related entities faster. The problem is that it also caches explicitly provided CimSessions that it does not own the lifetime of. So, if you ever use a CimSession with a Hyper-V cmdlet, then close that session, Hyper-V will try to use that disposed CimSession for any future interaction with the host in question. This is wrong, you can't cache objects with a lifetime you don't control without at least handling the case when that lifetime has been ended by the actual owner of the object.
Repro:
$someHyperVServer = 'myserver'
$cimSession = New-CimSession -ComputerName $someHyperVServer
get-vm -CimSession $cimSession
Remove-CimSession $cimSession
get-vm -ComputerName $someHyperVServer
The last command will throw an ObjectDisposedException.
