Category Archives: PowerShell and CIM

Testing Windows activation

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 “Windows*” if ($ta.LicenseStatus … Continue reading

Posted in PowerShell and CIM | 1 Comment

Volume friendly name

When you use Get-Volume one of the properties displayed is the friendly name PS> Get-Volume -DriveLetter C DriveLetter FriendlyName FileSystemType ———–     ————          ————– C                                                NTFS In this case its blank because I haven’t set a volume label. If you try … Continue reading

Posted in PowerShell and CIM | Leave a comment

Logon sessions

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 … Continue reading

Posted in PowerShell and CIM | 1 Comment

Windows Server 2019 updates with CIM

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 … Continue reading

Posted in PowerShell and CIM, Windows Server 2019 | Leave a comment

CIM_Component class

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 … Continue reading

Posted in PowerShell and CIM | Leave a comment

File searches with 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 (   … Continue reading

Posted in PowerShell and CIM, PowerShell and WMI | Leave a comment

user logon time

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 … Continue reading

Posted in PowerShell and CIM, PowerShell and WMI | Leave a comment