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

Author Information

Philip is a IT solutions engineer working for AmWINS Group, Inc., an insurance brokerage firm in Charlotte, NC. With a focus on data center technologies, he has built a career helping his customers and his employers deploy better IT solutions to solve their problems. Philip holds certifications in VMware and Microsoft technologies and he is a technical jack of all trades that is passionate about IT infrastructure and all things Apple. He's a part-time blogger and author here at Techazine.com.

One Response to “Reload inaccessible or invalid VM’s with this PowerCLI one-liner”

  1. Sean #

    THANK YOU!!!! This was exactly what I needed!

    November 16, 2017 at 9:37 am Reply

Leave a Reply

%d bloggers like this: