Quick Reference: PowerCLI One-Liners – Post 1 (of many!)

I’m one of those people who on the quiet really enjoys (I know…) the scripting aspect of working with Infrastructure and Cloud technologies.  What started out as writing VBscript logon scripts to map printers and drives on Windows XP with Windows 2003 DC’s (i.e. pre-GPP days) really has come a long way.  There was always something satisfying about getting the technology to provide consistent, time-saving results that provided value to the business, whether directly or indirectly.  I could never be a full-time developer, looking at the ISE for a week or so is more than enough for me in one hit!  I do however enjoy a project that has lots of automation requirements and/or potential.

In time I’ll be releasing some full scripts in this section but to get things started I wanted to share a random collection of useful PowerCLI one-liners.  You may have used these or ones like them before, or you may have your own that you find yourself using.  If you do please share them in the comments, I’d like this blog to be as interactive as possible to give maximum benefit to all that read it.  I think we all know that we do indeed work better when we work together…


Start/Stop host Tech Support Mode (SSH/Shell) Services

Very useful and far quicker than clicking about the Web Client to start these.  This example is based on a single cluster but could equally target a Datacenter, Single Host or with no filtering at all.


Rescan cluster host HBAs for devices & VMFS volumes

Very simple one this time but extremely useful for those of you with environments using lots of block based storage.


Get snapshot info for all VMs

Get all snapshots across all VMs in the inventory and retrieve useful data for review.


Get key attributes of RDM Disks attached to VMs based on a name filter

I’ve recently been working on a project involving migration of Virtualised SQL Clusters using Raw Device Mappings between storage platforms.  This neat one-liner came in handy several times.


Get datastore capacity utilisation including VM Count per datastore

This is a useful little one-liner for when you’re looking to review capacity and VM count distribution across datastores.  Simple but effective.

I hope these are useful to somebody.  I’ve got many more lined up to share over the coming weeks/months so keep checking back for additional posts where this came from.

Now go forth and automate!!


One thought on “Quick Reference: PowerCLI One-Liners – Post 1 (of many!)

Leave a Reply

Your email address will not be published. Required fields are marked *