PowerShell for Windows Admins:

WMI


July 11, 2017  12:35 PM

Linking disks, partitions and logical drives

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

A question of the forums was asking about discovering disk information. They were trying to pipe the output of Get-WmiObject into another Get-WmiObject. that won’t work. There is another way. On Windows machines physical drives are divided into 1 or more partitions which are each divided into one...

June 30, 2017  12:59 PM

Finding a CIM class

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

One of the problems you might find is finding a CIM class. You know its name but you don’t know which namespace its in. The old WMI cmdlets allow you to search the namespaces recursively

PS> Get-WmiObject -Class Win32_Process -Namespace root -Recurse -List


 NameSpace:...


June 12, 2017  7:57 AM

Find the logged on user

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

One method of finding the logged on users is to use CIM

$ComputerName = $env:COMPUTERNAME
Get-CimInstance -ClassName Win32_Process -ComputerName $ComputerName -Filter "Name = 'explorer.exe'" | 
foreach {
    
    $lguser = Invoke-CimMethod -InputObject $psitem -MethodName...


January 27, 2017  4:48 AM

wmic deprecated

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

I saw a forum post today where the question involved the use of the wmi command line tool wmic. Wmic was deprecated in Windows Server 2012 - 0 Comments     RSS Feed     Email a friend


December 22, 2016  1:54 PM

Applying updates through WSUS

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, Windows Server 2016, WMI

I like to keep the virtual machines in my test lab up to date so have a WSUS server to download and manage updates. The difficulty is applying the updates. With Windows 2012 R2 I used a module that would contact the WSUS server and apply the updates – the was especially useful on server core...


November 4, 2016  10:51 AM

ComputerName parameters for CIM and WMI cmdlets

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

Accessing a remote system and running Get-WmiObject -ClassName Win32_LogicalDisk -ComputerName $computer or Get-CimInstance -ClassName Win32_LogicalDisk -ComputerName $computer is a standard approach. If you’re creating a function with that code in you may put the local machine as...


November 4, 2016  10:03 AM

Working with multiple CIM objects

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

Many of the CIM objects we work with in our computers come in multiple instances – disks and network cards are a couple of examples. Many times when you see examples you’ll see something like this: $disks = Get-WmiObject -Class Win32_LogicalDisk foreach ($disk in $disks){ if ($disk.Size...


October 18, 2016  2:07 PM

Server Uptime

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

Its easy to get the last boot time of a Windows machine but how do you get the uptime function Get-Uptime { [CmdletBinding()] param ( [string]$ComputerName = $env:COMPUTERNAME ) $os = Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $ComputerName $uptime = (Get-Date) -...


October 4, 2016  12:50 PM

Filter early and WQL

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

What’s wrong with this: Get-CimInstance -ClassName Win32_Service | where {$_.State -eq 'Running' -and $_.StartName -notlike 'LocalSystem' -and $_.StartName -notlike 'NT Authority*'} | select PSComputerName, Name, DisplayName, State, StartName Nothing except that its inefficient. if you...


September 16, 2016  12:45 PM

Dealing with CIM properties that are integer arrays

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

Saw a post about WmiMonitorID that intrigued me If you use the WmiMonitorID: PS> Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorID | select -f 1 Active                 : True InstanceName           :...


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: