Using CimCmdlets to connect to CIM provider with Powershell and VMware

I needed to retrieve hardware status on memory DIMM’s and used PowerCLI, Powershell to retrieve the data.  Note the script assumes you have a text file list of servers.

#Reference articles
#https://communities.vmware.com/thread/446593
#http://www.virtu-al.net/2012/10/29/using-powershell-v3-0-cim-cmdlets-with-vmware-esxi-hosts/
#http://technet.microsoft.com/en-us/library/jj553783.aspx
#http://www.powertheshell.com/additional-cim-cmdlets-for-download/
#http://blogs.msdn.com/b/powershell/archive/2012/08/24/introduction-to-cim-cmdlets.aspx
#Import-Module : The specified module ‘CimCmdlets’ was not loaded because no valid module file was found in any module directory.

#$Server = “esxiServer1″
#$HostUsername = “root”
#$HostUsername2=Get-Credential
#$CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl
#$Session = New-CimSession -Authentication Basic -Credential $HostUsername2 -ComputerName $Ipaddress -port 443 -SessionOption $CIOpt
#$Result = Get-CimInstance -CimSession $Session -ClassName CIM_Chip | where {$_.CreationClassName -eq “OMC_PhysicalMemory” } | Select Caption,DataWidth,FormFactor,MaxMemorySpeed,@{N=”CapacityGB”;E={[math]::Round($_.Capacity/1GB,0)}}

Import-module CimCmdlets

#$HostUsername = “root”
$HostUsername=Get-Credential

$serverlist=get-content -path ServerList.txt
foreach($server in $serverlist)
{
    $CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl
    $Session = New-CimSession -Authentication Basic -Credential $HostUsername -ComputerName $server -port 443 -SessionOption $CIOpt
    $Result = Get-CimInstance -CimSession $Session -ClassName CIM_Chip | where {$_.CreationClassName -eq “OMC_PhysicalMemory” } | Select Caption,DataWidth,FormFactor,MaxMemorySpeed,@{N=”CapacityGB”;E={[math]::Round($_.Capacity/1GB,0)}}

    foreach(  in $Result)
    {
        Write-Host $DIMM
    }
}