Many of you like me have a lot of time and energy invested in Wmi or Vbs scripts and leaning a new programming language can seem quite overwhelming. With PowerShell you can use PowerShell’s Get-WMIObject Cmdlet to access all the classes from the Root\Cimv2 Namespace by default.
This will allow you to be able to use PowerShell with your current knowledge of WMI as in the two simple examples below. Simply open up the PowerShell command prompt or type PowerShell from the Start – Run line and paste in either of the following and press ‘Enter’:
WmiObject Win32_Account
WmiObject Win32_ComputerSystem
To go one step further as mentioned above the default for the Get-WMIObject Cmdlet is the Cimv2 namespace. However this can be changed by adding the –NameSpace parameter after Get-WMIObject as in the examples below:
Get-WmiObject -NameSpace Root\CCM -Class Sms_Client
Get-WmiObject -NameSpace Root\CCM -Class Sms_Client | Select-Object ClientVersion
This is all very good for looking at the local host machine but what if you want to see the SMS client version for a remote machine? PowerShell also allows you to do that as well by specifying the –ComputerName parameter after you reference the class as in the example below:
Get-WmiObject -NameSpace Root\CCM -Class Sms_Client -ComputerName Machine_Name | Select-Object ClientVersion
Howdy Don!
> Get-WmiObject -NameSpace Root\CCM -Class Sms_Client -ComputerName Machine_Name | Select-Object ClientVersion
This brings back all properties and then selects one property. You can be more efficent by specifying the -PROPERTY parameter on the Get-WmiObject cmdlet. You can specify one or more propertynames (no globbing) and it will retrieve just those properties. Of course it always includes the base WMI properties like __SERVER which tells you which machine it came from.
Try this one out:
Get-WmiObject -NameSpace Root\CCM -Class Sms_Client -ComputerName Machine1,Machine2,Machine3 -Property ClientVersion |Format-Table __Server,ClientVersion
Cheers!
Jeffrey Snover [MSFT]
Windows PowerShell/Aspen Architect
Microsoft Corporation
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx