-
-
Save pbt39ppc/b18c748ce4454d6c5e6edeafc8631c67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From http://blog.mattvogt.net/2013/02/08/vms-grayed-out-after-nfs-datastore-restored/ | |
#Get Inaccessible Virtual Machines | |
$VMs = Get-View -ViewType VirtualMachine | ?{$_.Runtime.ConnectionState -eq "invalid" -or $_.Runtime.ConnectionState -eq "inaccessible"} | select name,@{Name="GuestConnectionState";E={$_.Runtime.ConnectionState}} | |
write-host "---------------------------" | |
Write-host "Inaccessible VMs" | |
write-host "---------------------------" | |
$VMs | |
#Reload VMs into inventory | |
Get-View -ViewType VirtualMachine | ?{$VMs} | %{$_.reload()} | |
#Show new state of reloaded VMs | |
$ReloadedVMs = Get-View -ViewType VirtualMachine | ?{$VMs} | select name,@{Name="GuestConnectionState";E={$_.Runtime.ConnectionState}} | |
write-host "---------------------------" | |
write-host "Reloaded VMs" | |
write-host "---------------------------" | |
$ReloadedVMs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment