PowerShell for Windows Admins

June 27, 2013  3:50 PM

PowerShell presentations

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Jeffrey Snover and Jason Helmick will be presenting by webcast 18 July 9am – 5pm (PDT) on “Getting started with PowerShell”

Details from http://powershell.org/wp/2013/06/27/a-special-presentation-on-getting-started-with-powershell/

A follow up day of presentations will occur in August delving further into scripting, automation and building tools

June 27, 2013  3:44 PM

Writable properties for a WMI class

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Do you know how to discover which properties on a WMI class, and therefore a WMI instance, can be modified?

Get-CimClass from the PowerShell 3.0 CIM cmdlets is the answer:

$class = Get-CimClass -ClassName win32_volume

The last command returns all of the properties in this format

Name : Description
Value :
CimType : String
Flags : Property, ReadOnly, NullValue
Qualifiers : {read}
ReferenceClassName :

Name : DriveLetter
Value :
CimType : String
Flags : Property, NullValue
Qualifiers : {read, write}
ReferenceClassName :

Notice the first one has a Flag of ReadOnly and the second one has a Qualifier of write. So the question becomes how can you filter on those two items?

If you run something like this:

$class = Get-CimClass -ClassName Win32_Volume
$class.CimClassProperties |
foreach {
if ($psitem | select -ExpandProperty Qualifiers | where Name -eq ‘write’){$psitem}
if (($psitem.Flags -split ‘, ‘) -notcontains ‘Readonly’) {$psitem}

You will see that some properties may not be Readonly but also aren’t writable such as:

Name : NumberOfBlocks
Value :
CimType : UInt64
Flags : Property, NullValue
Qualifiers : {MappingStrings}
ReferenceClassName :

In that case we need just the writable properties

Get-CimClass -ClassName Win32_Volume |
select -ExpandProperty CimClassProperties |
foreach {
if ($psitem | select -ExpandProperty Qualifiers | where Name -eq ‘write’){$psitem}

This brings the results down to three properties DriveLetter, IndexingEnabled, Label

The first and last I expected – IndexEnabled was new to me

June 27, 2013  1:58 PM

Automation tools?

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

In this post http://richardspowershellblog.wordpress.com/2013/06/23/opinionautomate-or-suffer/ I talked about the need for admins to learn to automate. A couple of comments brought up the need for tools to create our automation scripts.

I remember the 4th generation languages of the late 1980s & 1990s. The promised that you wouldn’t have to code – just drag & drop onto the designer, answer a few questions and your application was created.

The worked great – as long as you wanted a cookie cutter application that only had limited functionality and was dog slow.

Automating code generation, in my experience, is a hard task. Compare the PowerShell snippets that come out of AD Admin center or the Exchange Management Console with what you actually write. They are usually very verbose and include lots of stuff you don’t need.

If someone can create a tool that creates my code for me, with minimal input on my side then I’ll sign up for it. I suspect it’ll be a long time coming. Until then happy coding.

June 27, 2013  1:46 PM

Windows Management Framework 4.0

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The PowerShell 4.0 preview is now available. It comes as part of WMF 4.0

Windows Management Framework 4.0 Preview includes updates to Windows PowerShell, Windows PowerShell ISE, Windows PowerShell Web Services (Management OData IIS Extension), Windows Remote Management (WinRM), Windows Management Infrastructure (WMI), the Server Manager WMI provider, and a new feature for 4.0, Windows PowerShell Desired State Configuration (DSC).

Download is available at


Note: It only installs on these versions of Windows

– Windows 7 with Service Pack 1
– Windows Server 2008 R2 with Service Pack 1
– Windows Server 2012
Windows 8 is not an option

June 26, 2013  4:09 PM

Dropping a database

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

A question came up on the forum regarding dropping a database & I realised it was something I hadn’t done before.

SMO provides a set of classes for managing SQL Server. You get SMO when you install the SQL Server management tools

Import the module to load SMO assemblies

import-module sqlps

get the server object and view the databases
$server = New-Object Microsoft.SqlServer.Management.Smo.Server(“w12scorc”)

view the target database

drop the database and view the databases again

June 26, 2013  2:06 PM

RDP annoyance

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I’ve RDPing into a number of servers from different systems recently and the way the screen resolution changes to match your monitor size is annoying. If I use the shortcut to the session I get whatever sizes were set in the last session so often logon, curse when the size isn’t convenient and logoff and reset.

maybe I should just buy a giant monitor?

June 26, 2013  1:59 PM

Windows Server 2012 R2

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The Windows Server 2012 R2 preview is available on MSDN subscriber downloads. It has PowerShell v4!!!!

June 26, 2013  1:55 PM

Follow up on user group

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I did a test tonight and the sound is definitely better over Lync. The sound wasn’t perfect but was much better than Live Meeting. Actually, seemed usable.

The system seems a lot more responsive in terms of client screen refresh. When showing slides the client refreshes very quickly. Showing code seemed better – not as quick bet definitely better than Live Meeting. I’ll try a new microphone and see if that improves things

June 25, 2013  1:43 PM

UK PowerShell group

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

As you are probably aware the UK PowerShell group has been very quiet over the last few months. This has been due to my personal circumstances – hopefully now resolved.

I want to re-start the group and was wondering what people wanted.

When I started the group 6 years ago we were the only PowerShell user group in the world! Things have changed. Back then I could easily organise physical meetings where the personal contact and ability to talk to people who were also learning PowerShell was invaluable. Its not possible to get the venues these days so I switched to using Live Meeting. Not as satisfying but much easier from a logistics stand point. There are problems with sound quality over Live Meeting. I’ve tried it on a number of networks from a number of machines and the sound is poor at best and impossible to listen to at worst.

The big problem for any user group is finding speakers. There aren’t that many people willing to speak on any particular topic and many of them aren’t based in the UK.

At the moment I’m thinking of a web cast every other month. I can’t do every month – I just don’t have the time. If I can find other speakers to fill the gaps that will be great but I’m working on worst case. Six sessions a year I can manage.

This supposes that I can resolve the sound problems. I’m experimenting with Lync and hope that will solve the problem. if it doesn’t then a total rethink is required.

So the question to the PowerShell community – what do you want?

June 25, 2013  12:46 PM

The inverse association

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

In my last post I showed how to find the groups of which a local user is a member. A comment was left asking about the inverse relationship.

In this case we can just turn the code round.

Get-CimInstance -ClassName Win32_Group |
foreach {
$users = Get-CimAssociatedInstance -InputObject $psitem `
-ResultClassName Win32_UserAccount |
select -ExpandProperty Caption

$psitem | Add-Member -MemberType NoteProperty -Name ‘Users’ `
-Value ($users -join “;”) -PassThru

} | select Name, Users

Note: You can’t do this as a matter of course with all WMI relationships. Some relationships are one way in that A has a link to B but B has no way to link back to A unless you can find a property in common.

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: