Browse by Tags

All Tags » PowerShell and WMI (RSS)

Scripting Games - Win32_LogicalDisk or Win32_Volume

I have heard some discussions recently regarding whether Win32_LogicalDisk or Win32_Volume should be used in the answer to event 3 in the Scripting Games. The problem requires you pull the drive letter, drive size and freespace for local disks on the...

Scripting Games–filtering on remote server

In event 3 you have to get information on hard disk capacity.  I’ve only looked at the first couple of dozen scripts but seen this too many times Get-WmiObject -Class Win32_LogicalDisk | where DriveType -eq 3 or if you prefer the version 2 way Get...

Scripting Games-don’t repeat the work

There are some good features to this script but what really hurts is the two trips to the server for the Win32_Computersystem class Foreach ($IP in (Get-Content "C:\IPList.txt")) { $Name = (Get-WMIObject Win32_ComputerSystem -ComputerName $ip...

Scripting Games–how not to output data

I haven’t finished blogging about event 1 yet but this caught my eye. Things aren’t too bad until we hit the bunch of  write-host calls $wrks = (Get-Content -path C:\IPList.txt) foreach ($wrk in $wrks) {     $osver = Get-WMIObject...

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

CIM cmdlets vs WMI cmdlets–speed of execution

One question that came up at the summit was the comparative speed of execution of the new CIM cmdlets vs the old WMI cmdlets.  No of us knew the answer because we’d never tried measuring the speed. I decided to perform some tests. This first test...
Posted by RichardSiddaway | with no comments
Filed under:

Manning Deal of the Day – April 6 2013

My PowerShell and WMI book will be Manning’s deal of the day for 6 April 2013.  The deal will go live at Midnight US ET and will stay active for about 48 hours. This is your chance to get the book with a 50% discount. Use code dotd0406au at manning...
Posted by RichardSiddaway | with no comments

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

Filtering

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...
Posted by RichardSiddaway | with no comments
Filed under:

Account SIDs–hopefully my last word

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...
Posted by RichardSiddaway | with no comments
Filed under:

Account SIDs revisited

I realised there is an easier way to get the data function get-SID { param ( [string] $computername = $env:COMPUTERNAME ) Get-WmiObject -Class Win32_AccountSID -ComputerName $computername | foreach { $exp = "[wmi]'" + $( $_ . Element ) ...
Posted by RichardSiddaway | with no comments
Filed under:

Account SIDs

A question on the forum asked about finding the accounts and SIDs on the local machine. function get-SID { param ( [string] $computername = $env:COMPUTERNAME ) Get-WmiObject -Class Win32_AccountSID -ComputerName $computername | foreach { $da = ( ( $_...
Posted by RichardSiddaway | with no comments
Filed under:

Number of processors in a box

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 Vista...
Posted by RichardSiddaway | with no comments
Filed under:

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 )...
More Posts Next page »