Home > PowerCLI, Powershell, Virtualization, VMware > Three PowerCLI scripts for information gathering – VMs, Hosts, etc

Three PowerCLI scripts for information gathering – VMs, Hosts, etc

February 11th, 2014 Leave a comment Go to comments

 

I was on a vSphere upgrade review engagement recently, and part of this involved checking hardware and existing vSphere VI was compatible with the targeted upgrade.

To help myself along, I created a few PowerCLI scripts to help with information gathering to CSV for the VI parts – such as Host Versions, build numbers, VMware tools and hardware versions, etc… These scripts were built to run once-off, simply either by copy/pasting them into your PowerCLI console, or by running them from the PowerCLI console directly.

They can easily be adapted to collect other information relating to VMs or hosts. To run, just launch PowerCLI, connect to the VC in question (using Connect-VIServer) and then copy/paste these into the console. The output will be saved to CSV in the directory you were in. Just make sure you unblock the zip file once downloaded if you execute them directly from PowerCLI, otherwise the copy/paste option mentioned above will work fine too.

There are three scripts bundled in the zip file:

  • Gather all hosts under the connected vCenter server and output Host name, Model and Bios version results to PowerCLI window and CSV
  • Gather all hosts under the connected vCenter server and output Host name, Version and Build version results to PowerCLI window and CSV
  • Gather all hosts under the specified DC and output VM name and hardware version results to PowerCLI window and CSV

Short and simple scripts, but hopefully they will come in handy to some. As mentioned above, these can easily be extended to fetch other information about items in your environment. Just take a look at the way existing info is fetched, and adapt from there. Also remember that using | gm (get-member) on objects in PowerShell is your friend – you can discover all the properties and methods on PowerShell objects by using this, and use those to enhance your reports/outputs in your scripts.

 

  1. March 12th, 2014 at 02:43 | #1

    Sean, any problems with adding these scripts to a public PowerCLI github repo, with proper credits?

  2. March 12th, 2014 at 15:16 | #2

    Hi Rob,

    I’ve been meaning to add all my stuff to my own repo on github, but won’t get any time soon, so please go ahead. If you just add Sean Duffy and this blog URL to the top, that would be awesome. Thanks :)

  3. March 13th, 2014 at 19:12 | #3

    Sean,

    Thanks, will do! See http://rnelson0.com/2014/03/12/powercli-github-repo/ for repo details. No ETA yet, bum wrist so it’s been slower than I wanted. High rate of typos :(

  4. March 24th, 2014 at 12:34 | #4

    Three cmdlets added at https://github.com/rnelson0/powercli-modules/commit/7c852888b2390b4f6af6fe1eafd5b9db0fd65454. Get-VMHostBIOSInfo, Get-VMHostESXInfo, Get-VMHardwareInfo.

  1. No trackbacks yet.
*