Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbt39ppc/b18c748ce4454d6c5e6edeafc8631c67 to your computer and use it in GitHub Desktop.
Save pbt39ppc/b18c748ce4454d6c5e6edeafc8631c67 to your computer and use it in GitHub Desktop.
# 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