Reload inaccessible or invalid VM’s with this PowerCLI one-liner

Can I let you in on a secret?  Although I blog to help others through my own experiences and troubleshooting, one of the other things I do is use my blog as my own personal knowledge base.  Once I’ve hit something, if I blog it, its there for me as much as you…

One of the problems I have run into several times are “inaccessible” or “invalid” VM in vCenter after a storage outage.  The only solution that I had found was cumbersome.  I had to unregister the VM from vCenter, browse to the appropriate datastore (which is more difficult today with storage pools obfuscating view), then locate the VMX file and register again.  While it works, its neither elegant nor fast.

But, thanks to Matt Vogt’s and Mike Letschin’s research and blog post, there is a much more acceptable solution to recover from this.  Matt’s post focuses on NFS storage, but from my personal experiences, its possible with a Fibre Channel outage and iSCSI, too.  If you have a storage outage and then discover “inaccessible” or “invalid” VMs, you can try the reload function through PowerCLI.  For the full details, check out Matt’s blog on the topic.

Matt links to a French language blog, hypervisor.fr, and I really like the PowerCLI one-liner that I found there.  It was quick and effective to reload the VM’s.

(Get-View -ViewType VirtualMachine) |?{$_.Runtime.ConnectionState -eq "invalid" -or $_.Runtime.ConnectionState -eq "inaccessible"} |%{$_.reload()}

Tags: , , , , ,

 

About the Post

No comments yet.

Leave a Reply

%d bloggers like this: