Using PowerShell v3.0 CIM cmdlets with VMware ESXi Hosts

I noticed that in PowerShell V3.0 some CIM cmdlets were introduced which allowed PowerShell to be able to interact with CIM providers and gather information, when importing the CIM Cmdlets into my session you can see we have a number of new cmdlets to work with:

image

Even though I know PowerCLI 5.1 R1 (Current release on 29th Oct 2012) does not support PowerShell v3.0 I thought I would check out what I could do with these and what information I could receive using the CIM cmdlets.

As a reminder, Carter Shanklin did some work in this area a long time ago and he ended up writing a function to be able to pull CIM information from ESX hosts, this can be found here, he also includes some links to documentation on the CIM providers the VMware hosts can provide: http://blogs.vmware.com/vipowershell/2009/03/monitoring-esx-hardware-with-powershell.html

As you will see from the video below the new cmdlets cut out most of the hard work Carter had to do and allow us to pull CIM information from the ESXi hosts with ease.

Using PowerShell v3.0 CIM Cmdlets with VMware ESXi Hosts from Alan Renouf on Vimeo.

For your reference, here is the code I used during this demo:

import-module CimCmdlets
$ipaddress = "10.20.177.15"
$HostUsername = "root"
$CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl
$Session = New-CimSession -Authentication Basic -Credential $HostUsername -ComputerName $Ipaddress -port 443 -SessionOption $CIOpt
Get-CimInstance -CimSession $Session -ClassName CIM_Fan

-Alan

Alan

Alan Renouf has a role of Automation Frameworks Product Manager at VMware responsible for providing the architects and operators of the cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/vipowershell and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

You may also like...

2 Responses

  1. November 29, 2012

    [...] CIM is an open industry standard and is used by non Microsoft devices and products as well. By example use it with network devices, storage devices and VMware. [...]

  2. February 1, 2013

    [...] Alan Renouf: Alan has a couple interesting articles this week – the first on pulling CIM information from an ESX hosts. It’s partly to do with improvements in PowerShell v3.0 rather than our own PowerCLI. As I [...]

Leave a Reply

%d bloggers like this: