Quantcast
Channel: WMI – PowerShell for Windows Admins
Browsing all 140 articles
Browse latest View live

Cim session oddity

The CIM cmdlets were introduced with PowerShell 3.0.  You can use the –ComputerName parameter to access a remote machine or, if you need to run multiple commands to the remote machine, you can create a...

View Article


WMI Filters

A common mistake with WMI/CIM filters is: PS>  Get-WmiObject -Class Win32_LogicalDisk -Filter “DeviceId=C:” Get-WmiObject : Invalid query “select * from Win32_LogicalDisk where DeviceId=C:” At...

View Article


WMI classes and Storage cmdlets

There is a hierarchy of objects to work through when dealing with disks First you have the physical disk PS>  Get-CimInstance -ClassName Win32_DiskDrive | fl Partitions : 5 DeviceID   :...

View Article

Optimising WMI calls–part 2

Last time we looked at using CIM sessions to make a set of WMI calls run quicker. This time we’ll reduce the number of calls.  I’m deliberately just reducing the number of calls to the Win32_Service...

View Article

Optimising WMI calls–part 3

The next change just uses 1 call to get the disk information instead of 2 Measure-Command -Expression { $srvs = ‘W16TP5TGT01’, ‘W16TP5TGT02′ for ($i=1; $i -le 150; $i++){ foreach ($srv in $srvs) { $cs...

View Article


Dealing with CIM properties that are integer arrays

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

View Article

Filter early and WQL

What’s wrong with this: Get-CimInstance -ClassName Win32_Service | where {$_.State -eq ‘Running’ -and $_.StartName -notlike ‘LocalSystem’ -and $_.StartName -notlike ‘NT Authority*’} | select...

View Article

Server Uptime

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

View Article


Working with multiple CIM objects

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

View Article


ComputerName parameters for CIM and WMI cmdlets

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

View Article

Applying updates through WSUS

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

View Article

wmic deprecated

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

View Article

Find the logged on user

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

View Article


Finding a CIM class

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

View Article

Linking disks, partitions and logical drives

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

View Article


CIM not 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?...

View Article

Examples of replacing WMI cmdlet with CIM cmdlet

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

View Article


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

View Article

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

View Article

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

View Article
Browsing all 140 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>