Saturday, August 25, 2012

Announcing PowerShell V3 PowerCamp – October 27/28 2012 in London

Now that the summer is (nearly) over, it’s time to get back to what mattes. With the imminent arrival of both Server 2012 and Windows 8 to general availability, learning PowerShell is now, more than ever, something every IT Pro needs to do! One great way to get up to speed is via my PowerShell PowerCamp events!

What is A PowerShell PowerCamp?
PowerCamp is a fast paced weekend training event that covers all the basic aspects of Windows PowerShell v3 - from the command line to writing production-oriented scripts. We start with the basics including configuration, formatting and providers and remoting and jobs. Then, on day 2, we look at scripting, work flows, managing script libraries using modules, WMI/CIM,  using objects, and finishing with the PowerShell features added into Windows. The event concludes with a short look at PowerShell in the cloud and a quick call out to all the things we just can’t cover in two days.

The PowerCamp event is a combination of lecture, demonstrations plus Q&A, with the opportunity to type along with the tutor. There are no formal labs. But I do provide the key demos, all the slides, plus a wealth of other add on material on a memory stick you get at the start of day 1. So bring along your laptop, and type away.

What is the Agenda?
Day 1 – The Basics
• PowerShell Fundamentals – starting with the key elements of PowerShell (Cmdlets, Objects and the Pipeline) plus installation, setup, and profiles
• What’s new in v3 – this looks at the things specifically added into PowerShell v3.
• Formatting – how to format output nicely – both by default and using hash tables and display XML
• Providers – getting into underlying OS data stores (certificate store, AD, registry, etc.) via providers
• Remoting and jobs– working with jobs plus working with remote systems using PowerShell’s remoting capabilities

Day 2 – Diving Deeper
• Scripting Concepts – automating everyday tasks including PowerShell’s language constructs, error handling and debugging and workflows
• Modules – managing PowerShell script libraries in the enterprise
• WMI and CIM – we look at the WMI and CIM components, including the new CIM cmdlets
• Using .NET and COM Objects – working with native objects
• PowerShell in Windows 2012 and Windows 8 – a look at what’s there and how you can leverage the huge number of new cmdlets
• PowerShell and the cloud – this module looks at PowerShell in the cloud and how you can use PowerShell to manage cloud computing.

What does it cost?
The cost is £200 (+VAT at the prevailing rate) for the weekend. Meals and accommodation are not covered.

Where is the event going to take place?
The PowerShell PowerCamp is being held at Microsoft Cardinal Place, 100 Victoria Street in Victoria on the weekend of October 27/28 2012. Each day starts promptly at 09:00 and finishes up by 16:45. We’ll also take short break throughout the day, including a 1-hour lunch break

After Saturday’s session, attendees are invited to a small nearby public house for some lovely English ale, etc.

Who is the tutor?
The PowerShell Weekend PowerCamp is delivered by Thomas Lee. Thomas is a veteran PowerShell MVP who has been involved in the PowerShell community since the very beginning. He provides training and consultancy around a range of Microsoft products, with a recent focus on PowerShell and Lync Server. Thomas runs PowerShell training courses around the world, and has been a speaker at conferences across the world for the past decade. In his spare time, he lives with his wife, daughter, wine cellar, and Grateful Dead live recordings archive in a small cottage in the English countryside. His Twitter handle is @DoctorDNS and he maintains two blogs (Under the Stairs at and PowerShell Scripts Blog at

What do I need to bring
You need to bring a laptop with PowerShell v3 loaded. That can be either native or in a virtual machine. I suggest you have at least two VMs pre-configured – one a server 2012 installation the other a Windows 8 installation. The virtualisation software is not of concern – but you need 64-bit guest OS support for Server 2012! Thus you can use Hyper-V, VMware Workstation or Oracle’s Virtual Box. Heck, run it in a VM on a Mac or Linux PC if you want. Just bring along PowerShell v3!

How do I book?
Contact to book a place and to arrange for the invoice to be paid. Payment must be in cash, cheque or bank transfer – I don’t take credit cards.

More Details
Watch this blog for any hot breaking news on the event.


Taming Wild Console Applications in PowerShell v3

One of the great features of PowerShell, especially for beginners, is that you can easily run old console applications that were originally written to be run under CMD.EXE. These are can be managed or unmanaged applications as well as older VBScripts. PowerShell, and PowerShell v3, just runs them. However, there is a fundamental problem which can often trip up those new to PowerShell (and from time to time us oldies too!).

In PowerShell there is a single parser therefore a single syntax that each and every cmdlet, function, script object, etc., have to obey. There’s only one parser, therefore there’s only one way to call a script/function/workflow/etc. This consistency is is wonderful. Compare that to older console line applications where each application implements it’s own parser, implementing an application unique syntax for usage. Compare NetShell, with it’s hierarchical contexts with calling IPconfig that uses the ‘/’ character to prefix parameters.

For the most part, the syntax you use when running a console application in CMD.EXE is the very same as you would run in PowerShell. So that’s all good then. Well – there are exceptions. There are some console applications whose command syntax confuses PowerShell’s parser. That is, the way PowerShell’s parser parses the call to that application does not quite do what you want. My favorite example is BcdEdit.exe. According to TechNet, you can use BcdEdit to add a native-boot VHD to an existing WIn7 boot menu (and appears to work just fine for Win8 too!) using the following commands:

bcdedit /copy {default} /d "vhd boot (locate)"
bcdedit /set {guid} device vhd=[locate]\windows7.vhd
bcdedit /set {guid} osdevice vhd=[locate]\windows7.vhd
The problem here is that BcdEdit wants arguments that are enclosed in brace characters – PowerShell sees text inside a pair of braces as a script block, not just a string that happens to have a pair of brace characters at the start/end. The result is that the command will not do what you want. There are often discussions on various PowerShell Forums. The solution rationally was to add quote characters, e.g.:
bcdedit /set “{guid}” osdevice vhd=[locate]\windows7.vhd
Which works, but is not always obvious. There are other examples which are even harder to fix quickly. The problem this causes is that it ‘proves’ to those who want it to, that PowerShell is not quite ready. The reality is that moving from one older inconsistent regime to another hopefully consistent regime was bound to turn up a a few minor incompatibilities. These areas are ones that came in for a lot of attention in PowerShell v3.
For those facing this issue, one of the cooler features in PowerShell v3 is the –% operator (that is: two hyphens and a percent symbol). You specify this character sequence after the command name but before the command’s parameters, like this.
bcdedit –% /set {guid} osdevice vhd=[locate]\windows7.vhd
What this character sequence does it to tell PowerShell to just pass the rest of the command line to the console application ‘as is’. This means you can old .bat scripts into .ps1 scripts, incorporating new PowerShell features for example, but being able to convert the calls to some curiously written console applications. 

Wednesday, August 22, 2012

My First Windows 8 Bug–PowerShell to the Rescue

Unless you are living in a cave, high in the Himalaya, you must have heard that Windows 8 made it to release. After a long wait, it was finally made available on TechNet – and I downloaded it as quickly as I could. My first action for any new OS build these days is to fire it up in a VM and see what’s there, which I duly did. The Installation process, which we first saw with Vista, is quick and my VM was ready in a flash. Since this is a VM I plan to keep and use, I went to activate it.

To activate Windows 8, you bring up the PC Settings:


Clicking Activate brings  up this message:



Bringing up the Action Center/Windows Activation, and I get this error screen:



Notice the red squared items. It shows a partial key (no idea where it got that from as I never entered one!). And it shows an Activation Error – DNS name does not exist. WHAT?  On the assumption that this error message was vaguely right, I spent some time trying to see what DNS issues there might be – needless to say I found nothing obvious. I moved the VM around, changed VM networking, etc. but to no avail.

I then spent some more time trying to work out how to add the correct key. I assumed that a) the error was nothing to do with DNS, and b) the real error was invalid key. But there seems to be no way, in this ‘fast/fluid’ dialog box, to add a key. I never was able to work out how to do that from the GUI, and the built in help text referred to dialog boxes that did not appear to exist.

Just as I was about to give up and turn to TechNet forums for help, I remembered a trick I used to use in some MOC Classroom setups where I continually had licensing problems. Naturally, these days, the solutions is almost always PowerShell based or at least invoked from PowerShell!

So after firing up PowerShell, in an elevated prompt, I ran the SLMGR.VBS utility, which brings up several pages of help text. On the first page I saw this (NB: if you click OK on the first page, the script brings another page of help text, and another  – there are several!).

Here’s what I see on the first page:




So,in the elevated PowerShell prompt, I just entered two quick commands as shown below. Of course, my key is not really FFFFF-EEEEE-etc., but you get the idea.


After typing 'slmgr –ipk <key>’, I get the following dialog box (which shows the real key I entered – but I’ve blacked that out for the purposes of this blog post):


After entering a key, successfully, I just entered ‘slmgr /ato’ to bring up this (also masking out my real key):



So once again, PowerShell to the rescue of the ‘fast/fluid/fail’ that seems, to me, to sum up Windows 8.  Thinking about it, this is the sort of problem you see in  a product that was not well enough tested (aka rushed out before it’s ready). Why wasn’t this tested fully and this bug found and fixed? And a second question – why do I need to use VBScript? Has the Windows activation team not heard of PowerShell?

I suppose all’s well that ends well – my VM is activated and I know how to do it again when I need to. But it leaves me with an unpleasant feeling – if something so fundamental as activation is broken, what else is? I guess we’ll find out soon enough.


I wrote the outline of this blog post last night and did most of the screen shots and posted it this morning. After doing so, I see from my mail box that I am not the only person to have found this bug (and solved it). Having said that, I think I’m the only person who used PowerShell!  So apologies if you beat me to it!

Friday, August 17, 2012

PowerShell Version 3 – Help Soon Coming

As I blogged in March, PowerShell V3 comes with Updatable help. This is a fantastic new feature that allows for Microsoft, and any PowerShell module maker, to create updated help for the code in their modules. Thus errors can get fixed in the in-box help. The implementation Microsoft chose is not perfect – there is only minimal help ‘in the box’. You have to use Update-Help in order to get the help contents. I regard this as a bug, but Microsoft describe it as a feature. Irrespective, I do like this feature!

Now that Windows 8 is released, so is PowerShell V3. Sadly, not all the help text has been released. Given the thousands of new cmdlets that ship with V3 and Server 2012, this is not surprising. While it would have been nice to think that help text is a sufficiently important part of the product to complete before RTM – that wasn’t the way it was done. So in order to get help in PowerShell V3, you will need to continue to use Update-Help. Once all the help text is available, I’ll try to post again!

One artifact of this situation is that Update-Help generates a couple of errors. Today, if you try to update help, you may see the following error:

Update-Help : Failed to update Help for the module(s) 'CimCmdlets' with UI culture(s) {en-US} : For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.
At line:1 char:1
+ Update-Help -force -verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : HelpInfoXmlValidationFailure,Microsoft.PowerShell.Commands.UpdateHelpCommand

The problem here is that the CimCmdlets (and possibly other modules) point off to Microsoft’s web site where Update-Help is meant to be able to find the updated help for this module (or modules). Sadly, the pointer from the module points to a nonexistent page, which Microsoft helpfully points off to Bing. That’s great for most things, but Update-Help gets the Bing page, which it tries to read as XML which is not quite right.

This is sad, but PowerShell updated help is still a work in progress – and given the magnitude of the task, I suppose the PowerShell Team can be forgiven. I must say, a LOT of modules have been updated over the past few days, and I would expect all the help text to be complete well before General Availability of Windows 8 and Server 2012.

Bottom line: Updatable help rocks, but we need just a bit of patience till it’s all here!


Monday, August 13, 2012

PowerShell Version 3 is RTM!

A few days ago, Microsoft announced that Windows 8 ( on August 1st according to Wikipedia). A key component of Windows 8 was the final release of Windows PowerShell version 3. Unfortunately, you (and i) can’t quite get it yet!

PowerShell V3 is going to come out in two ways:

  • In the box – when you get the RTM version of Windows 8 and Server 2012, you’ll get V3. Although you can run version 2 side by side, this does not work on initial installation – you need to install .NET v2.
  • Down-level Operating Systems – an updated version of the Windows Management Framework will ship sometime soon that contains all the necessary bits you need to run PowerShell v3 for down-level OSs. My understanding is that this will ONLY be supported on Server 2008, Server 2008 R2 and Windows 7 (i.e. no Vista).

Starting in a couple of days, customers will be able to download Windows 8 and Server 2012 and will have v3 in the box. The WMF update for down-level OSs will come some time after that.

Once the release is in my hands, I’ll be able to blog about all the cool features that are in v3!

Technorati Tags: