PowerShell – script to get WMI data, try CIM, then remoting then RPC

Get-CorpCimInfo

There are many scripts to get WMI data in the internet, but this script will use a unique technique. It will try getting remote data using many methods, preferring new ones and falling back to old legacy ones.

What is unique about this script is the amount of customization you can do with it. You can customize it completely just by adding one the script parameters and you are done.

If you run the script using -verbose mode, you will be presented with the right information for you to discover the power and logic of the script. Running the script by its own will not do anything as it is a wrapper function for you to use in other places where you need to get WMI data.

The script will basically get computer name or names, try to collect WMI information from them.

The script is smart enough to test if the remote computer is running PowerShell 3.0 at least and supports WS-MAN 3.0. If this is the case, the script will try to get WMI information by creating CIM session (Get-CIMSession).

If the script cannot connect to remote computer using CIM Session, then PowerShell remoting will be tried. If this fails too, the script will try to fall back to RPC call to get WMI data.

Get-CorpCIMInfo_232

Version 2 of the script

After a quick chat with Jeffery Hicks (@JeffHicks) who i based my script upon his own version, Jeff suggested couple of modifications on my version of the script, specifically the concept of always returning objects instead of strings or other types. After tweaking the script to do that and add more verbose and exception additional information, i came with version 2 of the script.

Download Get-CorpCimInfo_v3  

2 comments on “PowerShell – script to get WMI data, try CIM, then remoting then RPC

  1. Pingback: Get WMI data the right way – Get Disk info using WMI | Ammar Hasayen - Blog

  2. Pingback: Get Server Up Time in a smart way (WMI,CIM,Remoting) | Ammar Hasayen - Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s