Category Archives: PowerShell and CIM

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

WMI and CIM accelerators

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

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

CIM references and associations

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 show the end point of the link between CIM classes and REFERENCES shows the linking class. I … Continue reading

Posted in PowerShell and CIM | Leave a comment

CIM_ or Win32_

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

Posted in PowerShell and CIM | Leave a comment

Windows Updates CIM classes

When Windows 10 and Server 2016 were released they contained a new CIM namespace – ROOT/Microsoft/Windows/WindowsUpdate This contained a CIM class MSFT_WUOperationsSession that had 2 very useful methods – ScanForUpdates and  ApplyApplicableUpdates. These methods enabled you to find and install … Continue reading

Posted in PowerShell and CIM, WSUS | 1 Comment

Monitor resolution

A question on the forum about getting monitor resolution led to this code Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorId | foreach {        $filter = (“InstanceName = ‘$($psitem.InstanceName)'”).Replace(“`\”, “`\`\”)         $maxres = Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorListedSupportedSourceModes -Filter $filter … Continue reading

Posted in PowerShell and CIM | Leave a comment