- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Disconnect-VIServer * -Force -Confirm:$False
will kill your sessions to all connected servers.
One thing to keep in mind is if your code runs Connect-VIServer servername multiple times (or your code runs Connect-VIServer and stops before the matching Disconnect-VIServer and you run your script a bunch of times), then you have to run Disconnect-VIServer servername an equal number of times to get fully disconnected. Using * -Force disconnects everything.
$Global:DefaultVIServers | Where-Object {$_.RefCount -gt 1}
will show you which servers have been connected multiple times...