PowerShell for Windows Admins

April 21, 2015  8:42 AM

PowerShell Summit NA 2015–Day 1

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The third PowerShell Summit kicked off Monday 20 April with breakfast and a welcome from Don Jones and the powershell.org board.

The PowerShell Summit is the premier PowerShell event in the world with 3 days of  in depth PowerShell sessions delivered by the PowerShell Team, PowerShell MVPs and other acknowledged  PowerShell experts.

The attendees are extremely knowledgeable asking probing questions to keep the speakers on their toes.

DSC is a major theme with the opening sessions covering this topic –  Don Jones on resource design and Jason Helmick on using DSC to deploy IIS and PWA.

Other sessions included using DSC with Active Directory, and PowerShell for the reluctant DBA.

More esoteric topics included a look at PowerShell and Odata & Monitoring with PowerShell.

The day closed with the 140 attendees listening to Jeffrey Snover discussing the State of PowerShell – where its come from and where its going

April 9, 2015  10:32 AM

PowerShell Summit NA 2015 speakers

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Want to learn a bit more about some of the speakers at the PowerShell Summit?  Head over to the Scripting Guy blog – http://blogs.technet.com/b/heyscriptingguy/ – to see a series of posts giving you some background, and pictures, of a number of speakers.

April 6, 2015  5:39 AM

Query vs Filter

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

I’ve tended to advocate using the –Filter parameter rather than the –Query parameter with the CIM (and WMI) cmdlets but a recent post on the Windows Management Infrastructure blog has me questioning that decision.

Using Measure-Command I tried various pairs of commands – such as:

Measure-Command {Get-CimInstance -ClassName Win32_Directory -Filter “Name = ‘C:\\Test2′”}

Measure-Command {Get-CimInstance -Query “SELECT * FROM Win32_Directory WHERE Name = ‘C:\\Test2′”}

The results weren’t conclusive but it seems that at worst there is no significant difference between the approaches and at best using a query is significantly faster.

At the moment my best advice would be use the –Filter parameter if you want to reduce typing but try –Query if speed becomes your main issue.

April 1, 2015  9:38 AM

MVP renewal

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

April 1st comes round again and its time for the MVP renewals. I received my renewal email this afternoon – I feel highly honoured that Microsoft have bestowed an MVP award for 8 straight years.

Thank you

February 23, 2015  1:08 PM

PowerShell Europe 2015 Agenda

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

As has been announced registration for the PowerShell Summit Europe 2015 opens on 27 February 2015. http://powershell.org/wp/2015/02/20/powershell-summit-europe-registration/

Other details on the Summit can be found here:  http://powershell.org/wp/community-events/summit/powershell-summit-europe-2015/

The agenda for the Summit can be found on the event site for the Summit http://eventmgr.azurewebsites.net/event/home/PSEU15

February 21, 2015  2:40 PM

Change to DSC Resource Kit release strategy

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The PowerShell team blog http://blogs.msdn.com/b/powershell/archive/2015/02/13/new-and-improved-resource-kit.aspx details the new resources and bug fixes in wave 10 of the DSC resource kit. This is a much smaller release than the of late but includes new resources for initializing and formatting disks


One point in the “small print” is important to note. This is the last release of these resource as a big zip file for download from the TechNet script gallery. In future these resources will only be available through the PowerShell gallery. Use Find-DscResource to discover the resources available in the gallery and Update-Module & Install-module to get the modules containing resources from the gallery.

February 19, 2015  8:26 AM

DSC Resource Kit Wave 10

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The next release (wave 10) of the Desired State Resource Kit is available. You can download the whole of the resource kit from https://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d

This version includes the IIS resources that were missing in wave 9

February 19, 2015  2:54 AM

WMF 5.0 February 2015 preview

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

A new preview of Windows Management Framework 5.0 (PowerShell) is available. See http://blogs.msdn.com/b/powershell/archive/2015/02/18/windows-management-framework-5-0-preview-february-2015-is-now-available.aspx

for details. The release notes indicate which new features are considered stable and which are still regarded as experimental and therefore subject to change.

Downloads are available for Windows 8.1 (x32 and x64), Windows Server 2012 R2  Windows 2012. You will need .NET 4.5 installed.

February 18, 2015  1:31 PM

Copy a file with WMI

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

A question came up on the forum about copying files with CIM (WMI). I normally use Copy-Item rather than CIM as its easier. The questioner was using CIM_LogicalFile when I’ve normally used CIM_DataFile so I decided to take a look at the class. In reality the two classes are very similar and CIM-datafile could be substituted for CIM_LogicalFile in the code that follows.

The obvious starting point is to use the Copy method on the CIM_LogicalFile class

$files = Get-WmiObject -Class CIM_LogicalFile -Filter “Path = ‘\\Test\\’ AND Extension = ‘txt'”

foreach ($file in $files) {
$newfile = “C:\Test2\$($file.FileName).$($file.Extension)”



Couple of points to note. In the Path part of the filter you have to escape the \ delimiter.  Extension doesn’t include the ‘.’

You have to give the full path – including file name – to the loaction to which you want to copy the file. In this case you don’t have to escape the \ delimiter. Consistency is a wonderful thing and usually absent from WMI.

You can also use Invoke-WmiMethod

$files = Get-WmiObject -Class CIM_LogicalFile -Filter “Path = ‘\\Test\\’ AND Extension = ‘txt'”

foreach ($file in $files) {
$newfile = “C:\Test2\$($file.FileName).$($file.Extension)”

Invoke-WmiMethod -InputObject $file  -Name Copy -ArgumentList $newfile



use the new CIM cmdlets

$files = Get-CimInstance -ClassName CIM_LogicalFile -Filter “Path = ‘\\Test\\’ AND Extension = ‘txt'”

foreach ($file in $files) {
$newfile = “C:\Test2\$($file.FileName).$($file.Extension)”

Invoke-CimMethod -InputObject $file  -MethodName Copy -Arguments @{Filename = $newfile}


In this case you have to give the argument name for the method as well as its value. You can discover the method parameters using Get-CimClass

$class = Get-CimClass CIM_LogicalFile

£> $class.CimClassMethods[“Copy”].Parameters

February 17, 2015  1:37 PM

Shutting down machines in parallel

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Hyper-V, Powershell

My test lab is a set of virtual machines running on a Lenovo w1510 laptop. When I’ve finished working for the day I want to shut down the virtual machines and the laptop. I may have anywhere between 2 and 8 (or more) VMs running so scripting the shutdown helps a lot.

Machines can be shutdown independently so this is an action that is ideal for parallel execution through a workflow.

workflow stop-allvms {
$vms = Get-VM | where State -eq “Running”
foreach -parallel ($vm in $vms) {
Stop-Computer -PSComputerName $vm.Name -Force -Verbose


Get the running VMs. use foreach –parallel to run stop-computer against each VM. Notice I’ve had to change the parameter on Stop-Computer from –ComputerName to –PSComputerName

Another little workflow that makes life easier. I looks like workflows aren’t going to be the game changer that we originally thought but they do add some interesting options.

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: