PowerShell for Windows Admins:

WMI


March 11, 2013  2:07 PM

Network Adapters–Disable/Enable



Posted by: Richard Siddaway
PowerShell 3, Windows 8, Windows Server 2012, WMI

Last time we saw the Get-NetAdapter cmdlet from the NetAdapter module

PS> Get-NetAdapter | ft Name, InterfaceDescription, Status -a

Name    ...

March 4, 2013  2:23 PM

Network adapters



Posted by: Richard Siddaway
PowerShell 3, Windows 8, Windows Server 2012, WMI

The WMI classes Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration have seen a lot of use over the years. They can be a bit fiddly to use which is why the NetAdapter module in Windows 8/2012 is a so welcome.

Lets start by looking at basic information gathering

PS>...


February 18, 2013  4:32 PM

CIM cmdlets and remote access



Posted by: Richard Siddaway
PowerShell, PowerShell 3, WMI

When you used the WMI cmdlets

Get-WmiObject -Class Win32_logicalDisk -ComputerName RSLAPTOP01

You were using DCOM to access the remote machine. Even if you accessed the local machine you were using DCOM.

This changes in PowerShell v3 when using the CIM cmdlets.

If...


February 18, 2013  1:37 PM

Filtering



Posted by: Richard Siddaway
PowerShell, WMI

I’ve been grading the scripts in the warm up events for the Scripting Games and noticed a lot of people doing this:

Get-WmiObject -Class Win32_LogicalDisk | where {$_.DriveType -eq 3}

Ok now it works but there are a couple of things wrong with this approach.

Firstly,...


January 17, 2013  2:26 AM

Account SIDs–hopefully my last word



Posted by: Richard Siddaway
PowerShell, WMI

Ok the embarrassing moral of this story is that you shouldn't answer questions in a hurry at the end of the evening. 5 minutes after shutting down I realised that there is a far, far simpler way to get the info. Win32_AccountSID is a WMI linking class. It links Win32_SystemAccount and Win32_SID...


January 16, 2013  4:47 PM

Account SIDs revisited



Posted by: Richard Siddaway
PowerShell, WMI

I realised there is an easier way to get the data

function get-SID {            
param (            
...


January 16, 2013  4:21 PM

Account SIDs



Posted by: Richard Siddaway
PowerShell, Users, WMI

A question on the forum asked about finding the accounts and SIDs on the local machine.

function get-SID {            
param 			


January 5, 2013  6:20 AM

Number of processors in a box



Posted by: Richard Siddaway
PowerShell, WMI

WMI enables you find the number of processors in your system:

PS> Get-WmiObject -Class Win32_ComputerSystem | fl Number*


NumberOfLogicalProcessors : 2
NumberOfProcessors        : 1

This works fine for Windows...


January 3, 2013  1:11 PM

Displaying data from multiple servers as HTML



Posted by: Richard Siddaway
PowerShell, WMI

A forum question regarding retrieving WMI based data from multiple servers and displaying it as HTML was interesting.  I would approach it like this

$servers = Get-Content...


December 10, 2012  2:25 PM

Get-CimClass changes



Posted by: Richard Siddaway
CIM, PowerShell 3, WMI

One thing that I don’t think I’ve mentioned is that the Get-CimClass output changed during the development process.

In PowerShell v3 RTM you can dig into a WMI class like this

Get-CimClass -ClassName Win32_OperatingSystem | select -ExpandProperty CimClassMethods