PowerShell for Windows Admins:

CIM


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:...


December 21, 2017  12:08 PM

Windows Updates CIM classes

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WSUS

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...


October 25, 2017  5:32 AM

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

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...


September 27, 2017  1:47 PM

Examples of replacing WMI cmdlet with CIM cmdlet

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

Following my last post I was asked about these Examples of replacing WMI cmdlet with CIM cmdlet. Example 1 gwmi win32_operatingsystem -computername $Computer -credential $creds, $cs = New-CimSession -Credential $creds -ComputerName $computer Get-CimInstance -ClassName...


September 26, 2017  10:04 AM

CIM not WMI

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

I still see a lot of people using the WMI cmdlets – Get-WmiObject etc. You really should be using CIM nit WMI. In other words use Get-CimInstance rather than get-WmiObject etc etc. Why do I say that? Two main reasons. Firstly, the WMI cmdlets are effectively deprecated. Any further...


July 16, 2017  3:56 AM

Change a computer’s description

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

The Win32_OperatingSystem class exposes the machines Description. This is how you can easily change a computer’s description.

PS> Get-CimInstance -ClassName Win32_OperatingSystem | select Description

Description
-----------

PS> Get-CimInstance -ClassName Win32_OperatingSystem |...


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: