Monthly Archive


Monthly Archives: August 2010

PowerShell in Practice offer

Today Manning are offering 50% their best selling books including PowerShell in Practice.


See to order

PowerShell too hard?

In an article on the Windows IT Pro site - – Paul Thurrott states

But the problem with PowerShell is that it's so powerful its indecipherable to admins. PowerShell is arguably a full-blown development environment. It consists of a command-line shell, a .NET-based, object-oriented scripting language, and a runtime engine that can optionally be embedded in other applications. For the typically overworked admins and IT pros, PowerShell might be a godsend if they could actually use it. But I was of the mind in 2002—as I am today—that most admins and IT pros have a completely different set of skills and are overworked as it is. To really take advantage of PowerShell, you need to be a developer or learn those skills too. And finding people who have credible administrative and developer skills is quite a trick. If you're such a person, maybe it's time to ask for a raise.


Now I disagree totally with the crux of this paragraph for a number of reasons:

  1. PowerShell is not a full-blown development environment. You can do practically anything .NET based with it but just because you can doesn’t mean you should
  2. I know of many Windows administrators who have picked up PowerShell and learnt enough, quickly enough to be very productive and re-pay the time spent learning it many times over. There  is a sufficient body of knowledge available through the web – including articles in Windows IT pro that a PowerShell beginner can find the information they need to help solve their problem
  3. You do not have to be a developer to really take advantage of PowerShell – or any other scripting language. PowerShell is particularly good for the admin as it abstracts much of the .NET code into the cmdlets. If you use a cmdlet you don’t need to know, or even care, what .NET class is being used in the back ground.
  4. How much of a developer do you have to be to string cmdlets on the pipeline and come up with a powerful piece of functionality that solves your business problems now

In 2006/2007 when PowerShell was just getting started I might of agreed that starting with PowerShell could be viewed as a steep learning curve. Four years later I think it is a lot easier – again Windows IT Pro have published a number of articles on PowerShell – with much more information available.

I would turn this on its head and state that if you are a Windows administrator that isn’t using PowerShell you are making your life more difficult that it needs to be.

Rounding numbers

We often need to round numbers when we are writing administration scripts – for example

PS> Get-ChildItem c:\hiberfil.sys -Force | Format-Table Name, Length -AutoSize

Name             Length
----             ------
hiberfil.sys 2213351424


We need the force because hiberfil.sys is a hidden file.  Looking at the file size its about 2GB but its difficult to relate to a number that size so we can try this

PS> Get-ChildItem c:\hiberfil.sys -Force | Format-Table Name, @{Name="Size";Expression={$_.Length/1GB}} -AutoSize

Name                     Size
----                     ----
hiberfil.sys 2.06134414672852


However there are too may numbers after the decimal point – we don’t need that level of accuracy.  The easiest way to round the numbers is to use the Math .NET class.

PS> Get-ChildItem c:\hiberfil.sys -Force | Format-Table Name,

@{Name="Size";Expression={[math]::round($_.Length/1GB,2)}}  -AutoSize

Name         Size
----         ----
hiberfil.sys 2.06


Which gives us a nice easy to understand display

Lenovo W510, Hyper-V and BSOD

Beginning of the week I took delivery of a Lenovo W510 – i7 quad core with Hyper-Threading (Windows sees 8 cores) and 16GB of RAM.  From reviews I’d seen it seemed to run Hyper-V OK so it fitted the bill for a mobile lab.

Partitioned the disk OK and got Windows 2008 R2 installed.  Had to download a few drivers from the Lenovo (IBM) site but everything I needed was there or on the box already.  I’d ordered it with Windows 7 64bit so most of the drivers were available.

Installed Hyper-V and joined it to the domain.

Started moving Virtual Machines on to it and it started crash with a Blue Screen of Death.  Not good & I’m not amused at this point. Eventually got to the point where it wouldn’t start – continual BSOD.  Very not good – my new toy is going back if this continues!

Did some research and it seems there can be a conflict between core parking and Hyper-V.  Core parking is a power saving technology that puts cores to sleep if they are not being used. Hyper-V expects them to be there = BANG.

I booted into the BIOS screen and disabled the power management features on the CPU (and PCI bus for good measure) that enable core parking.  Restarted and everything now seems OK.

I can comfortably run a bunch of VMs and have a reasonable performance. 

Then I discovered that I had to reactivate Windows on all the VMs.  They’d been originally been running on a machine with AMD processor. New processor is Intel.  Its enough of a change to trigger reactivation.

All done and everything seems to work fine.

Time to get Virtual Machine Manager installed and see what that actually does.

PowerShell Tech tips

Two tech tips that I’ve contributed to the Realtime publishers site are now available

Go to

and look under Disaster Recovery for

How to Configure a Windows Server 2008 R2 Failover Cluster with Windows PowerShell


How to Configure Data Mirroring in SQL Server 2008 with Windows PowerShell



Manning Offers 1st August

Check today’s offers from – including 50% off print version of PowerShell in Practice