PowerShell for Windows Admins:

CIM


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

May 9, 2017  3:23 AM

Are your domain controllers real?

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Active Directory, CIM, Powershell

A question on the forum asked about discovering if domain controllers are physical or virtual machines. In other words Are your domain controllers real? This will do the job:

foreach ($domain in (Get-ADForest).domains) {
 Get-ADDomainController -filter * -server $domain |
 sort hostname...


April 26, 2017  1:41 PM

DiskPart and PowerShell–part 1

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

An attendee at the Summit made the statement that the DiskPart utility didn’t have any equivalent in PowerShell. That’s not strictly true as the storage module provides a lot of functionality that maps to diskpart functionality. The module contents include: PS> Get-Command -Module...


March 29, 2017  1:29 PM

Name mismatch

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Active Directory, CIM, Powershell

Ever wondered why you can’t do this:

Get-ADComputer -Filter * -SearchBase 'OU=Servers,DC=Manticore,DC=org' |
Get-CimInstance -ClassName Win32_OperatingSystem
The –ComputerName parameter on get-CimInstance accepts pipeline input BUT its by property name.
PS> Get-Help...


March 22, 2017  2:49 PM

Get-SupportedFileSystems

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

I stumbled on the Get-SupportedFileSystems cmdlet today. Its part of the Storage module and is defined as a function. Digging a bit further its from a CDXML module based on a CIM class. But which CDXML file contains the definition?

PS> Get-ChildItem -Path...


January 29, 2017  9:50 AM

Finding DNS static records

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, DNS, Powershell

An interesting question from the forums about finding DNS static records You can view the records in a DNS zone Get-CimInstance -Namespace root\MicrosoftDNS -ClassName MicrosoftDNs_Atype -ComputerName W16DC01  -Filter "DomainName = 'manticore.org'" | select OwnerName, Timestamp,...


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


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: