Browse by Tags

All Tags » PowerShell V3 » PowerShell and WMI (RSS)

WMI vs CIM speed tests–the final round

As a final test I want to see what happened when I ran multiple commands against the remote machine. PS> 1..100 | foreach { Measure-Command -Expression{1..100 | foreach { Get-WmiObject -Class Win32_ComputerSystem -ComputerName W12SUS; Get-WmiObject...

CIM vs WMI cmdlets-remote execution speed

Following on from my previous post we’ll look at how the two types of cmdlets compare for accessing remote machines. I used a similar format to the previous tests but was accessing a remote machine. First off was the WMI cmdlet – using DCOM to access...

Shutting down a remote computer

PowerShell provides the Stop-Computer cmdlet for closing down a remote machine. I find this especially useful in my virtual test environment. I’ll have several machines running but won’t necessarily have logged onto them. Using Stop-Computer means that...

CIM cmdlets

The CIM cmdlets are found in the CIMcmdlets module. Get-Command -Module CimCmdlets  produces this list of names.  I’ve added some information on the tasks they perform Get-CimAssociatedInstance  is for working with WMI associated classes...

WMI vs CIM

An email debate yesterday regarding the use of the CIM cmdlets (new in PowerShell 3) vs the WMI cmdlets made me realise that other people are probably wondering the same thing, The question is really part of a the semi-philosophical debate about when...

Network Adapters–Disable/Enable

Last time we saw the Get-NetAdapter cmdlet from the NetAdapter module PS> Get-NetAdapter | ft Name, InterfaceDescription, Status -a Name     InterfaceDescription                          ...

Network adapters

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

CIM cmdlets and remote access

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

Displaying data from multiple servers as HTML

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 -Path C:\scripts\servers.txt $data = @( ) foreach ( $server in $servers )...

Get-CimClass changes

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

New about files

PowerShell v3 features updateable help.  The help files are not quite complete at the moment but a recent update to the help that is available brought a couple of very useful files: about_WMI about_WQL The first gives a good overview of WMI and the...

WMI –property parameter

One parameter that seems to get overlooked on Get-WmiObject is the –Property parameter. It is used to specify the properties you want returned. This is what you would normally get by default: PS> Get-WmiObject -Class Win32_Service  | select -f...

Jobs, WMI, CIM and more jobs

Background jobs were one of the most undervalued aspects of PowerShell v2. With the introduction of PowerShell v3 we get ways to schedule those jobs. In this post though I want to look at the new CIM cmdlets and jobs. Using the WMI cmdlets most PowerShell...

WMI over WSMAN

Every time I look at PowerShell v3 I seem to find a new way to access WMI! I’ve covered the –ComputerName and –CimSession parameters before but to recap We duplicate the way Get-WmiObject works: $computer = $env:COMPUTERNAME Get-CimInstance -ClassName...

Finding the drive letter of a mounted VHD

In Windows 8/2012 you can mount a VHD into the file system. Is there a way to discover the drive letter of the mounted VHD function get-mountedvhdDrive { $disks = Get-CimInstance -ClassName Win32_DiskDrive | where Caption -eq "Microsoft Virtual Disk"...

Windows 8 Networking cmdlets

Windows 8 brings PowerShell v3 and a whole bunch of PowerShell modules.  One such module is NETTCPIP and as the name suggests is about networking. PowerShell v3 automatically loads modules for you so as soon as PowerShell opens try PS> Get-NetIPConfiguration...

WMI property names

A question brought it home to me that WMI property names don’t always mean what you might think they mean – this is also true of other objects but I tripped over this one with WMI so we’ll stick with that. PS> Get-CimInstance -ClassName Win32_Desktop...

Working with profiles: 2 deleting profiles

I recently (1 June) showed how to discover the user profiles on your system. Now its time to delete them. function remove-profile { param ( [ parameter ( Mandatory = $true ) ] [string] $username ) $user = Get-CimInstance -Class Win32_UserAccount -Filter...

Toggling between LAN and Wireless

One of the questions in the recent Scripting Games involved toggling between a wireless and LAN connection. Only one was to be up at any one time. This can be solved using WMI but becomes hugely simpler in Windows 8/2012 as we get a bunch of cmdlets for...

Working with profiles: part 1

A question came up on the forum for PowerShell and WMI – how do I delete profiles. I’m going to work up to answering that by looking at using WMI to work with profiles. So to start how can we find the profiles available on our system Get-WmiObject -Class...
More Posts Next page »