PowerShell for Windows Admins:

CIM


August 29, 2019  11:25 AM

Testing Windows activation

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

Testing Windows activation from PowerShell involves a little dive into CIM (WMI). At its simplest a function like this function test-activation { $ta = Get-CimInstance -ClassName SoftwareLicensingProduct -Filter "PartialProductKey IS NOT NULL" | Where-Object -Property Name -Like...

July 24, 2019  12:36 PM

Volume friendly name

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

When you use Get-Volume one of the properties displayed is the volume friendly name PS> Get-Volume -DriveLetter C DriveLetter FriendlyName FileSystemType -----------     ------------         -------------- C                                             ...


July 4, 2019  10:19 AM

Logon sessions

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

Saw a question about logon sessions that had me looking at CIM class Win32_LogonSession. I really don’t like the example code they have – code shouldn’t posted that contains aliases especially the abominable use of ? for Where-Object (pet PowerShell peeve number 3). Something like this is...


May 19, 2019  12:56 PM

Windows Server 2019 updates with CIM

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

Windows Server 2019 updates with CIM remain the same as all server versions post Windows Server 2016. This code will check for and install any updates. Micorosft Update or WSUS will be used depending on how your system is configured $au = Invoke-CimMethod -Namespace...


April 27, 2019  4:29 AM

CIM_Component class

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

I saw a question about the CIM_Component class and wondered what it was. So I tried it PS> Get-CimInstance -Namespace root\CIMV2 -ClassName CIM_Component | select -f 1 | fl * GroupComponent : Win32_Directory (Name = "<directory path>") PartComponent : CIM_DataFile (Name = "<file...


August 19, 2018  8:12 AM

File searches with WMI

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

I saw a question about file searches with WMI. If you just know the file name it’s a very slow process. Painfully slow. If you have an idea about the folder its much quicker. function get-wmifile { [CmdletBinding()] param ( [Parameter(Mandatory =...


August 15, 2018  8:23 AM

user logon time

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

Saw an interesting question about user logon time. How can you tell the logged on user and when they logged on $logon = Get-CimInstance -ClassName Win32_LogonSession | sort StartTime -Descending | select -First 1 $user = Get-CimAssociatedInstance -InputObject $logon -ResultClassName...


May 26, 2018  10:11 AM

WMI and CIM accelerators

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

In PowerShell an accelerator is a shortcut to a .NET type. The WMI accelerators have been around since PowerShell v1. The WMI accelerators were heavily used in v1 fill some of the gaps in cmdlet coverage. The CIM accelerators appeared in PowerShell v3 (I think – only discovered them recently!)....


April 24, 2018  1:09 PM

CIM references and associations

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

Way back in 2011, when I were just a young lad, I wrote about WMI or CIM references and associations - https://wordpress.com/read/blogs/16267735/posts/1673 ASSOCIATORS...


February 1, 2018  10:49 AM

CIM_ or Win32_

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

If you dig into the classes available on a Windows machine you’ll see a mixture of prefixes – namely CIM_ and Win32_ used for the classes. So which should you use CIM_ or Win32_ Lets start by seeing whats available:

PS> Get-CimClass -ClassName *Volume*


    NameSpace:...


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: