PowerShell for Windows Admins:

WMI


November 20, 2015  10:45 AM

Creating Registry Key

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

I had a question left on the blog asking how to create a registry key. My preferred method is to use the CIM class = StdRegProv. Its a static class so you don’t need to create an object [uint32]$hklm = 2147483650 $newkey = 'SOFTWARE\NewKey' Invoke-CimMethod -ClassName StdRegProv...

November 16, 2015  12:51 PM

Accessing WMI

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell, WMI

There are 3 sets of cmdlets for working with WMI classes – the WMI cmdlets, the WSMAN cmdlets and the CIM cmdlets. The protocols used by these 3 sets are different. The WMI cmdlets introduced in PowerShell 1 & 2 use DCOM for local and remote access under all circumstances The WSMAN...


November 11, 2015  2:00 PM

WMI wildcards and filtering

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

A question on the forum asking about filtering WMI results raises a number of interesting points. The user wanted to pass a computername and a filter term to pull product information from remote machines. I ended up with this $computername = $env:COMPUTERNAME $filter = 'Live' $scriptblock...


November 4, 2015  5:13 AM

WMI cmdlets and credentials

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell, WMI

If you’re working with the WMI cmdlets and need to pass credentials you’ll end up with a statement something like this Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer -Credential $cred If the computer name defaults to the local host or you use . or ‘localhost’ as the...


October 17, 2015  4:00 AM

WMI linked classes

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

You will find that many WMI classes have links – some are associations built in to WMI (a subject for another time) while other classes can be linked based on property values. An example of the latter is the Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration classes. The DeviceId on...


October 14, 2015  4:59 AM

NICs with IP addresses

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

A question on the forum asked about discovering those network adapters that had IP addresses configured. The user had tried PS> Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPAddress IS NOT NULL" Get-WmiObject : Invalid query "select * from...


September 29, 2015  1:42 PM

Win32_ReliabilityRecords Class

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

The Win32_ReliabilityRecords class was introduced with Windows 7. It contains information from the Windows Event Log related to system reliability. The most interesting properties are the Message and the TimeGenerated £> Get-WmiObject -class win32_reliabilityRecords | select -First 1 | fl...


July 28, 2015  5:26 AM

WMI dates

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

Dates as reported by WMI still seem to cause a lot of problems. If you use the WMI cmdlets £> Get-WmiObject -Class Win32_OperatingSystem | select *date* | fl InstallDate   : 20131205101649.000000+000 LocalDateTime : 20150728121320.002000+060   That format is year, month, day,...


July 14, 2015  12:05 PM

Disk identification

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell, WMI

A recent question on the forums regarded using the Win32_LogicalDisk class to retrieve disk size and free space data.  A filter based on the disk letter was being used. The main error with the code was that the filter was being expressed as "DeviceId='E'" rather than "DeviceId='E:" The...


June 29, 2015  12:06 PM

CIM filters

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

I was looking up Win32_SystemDriver on the MSDN site and noticed there was some PowerShell example code Get-WmiObject -Class Win32_SystemDriver | Where-Object -FilterScript {$_.State -eq "Running"} | Where-Object -FilterScript {$_.StartMode -eq "Manual"} | Format-Table -Property...


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: