Friday, December 21, 2012

PowerShell V3 Training

My main ‘day’ job is training, running courses in a variety of (mainly) Microsoft technologies including Lync and PowerShell. I teach the official Microsoft courses (I helped write both of them!), and have my own material that I’ve been running across Western Europe. With the release of PowerShell V3, I’ve created a new course which I was able to run for the first time this week on Trondheim Norway. It was the last week of work this year – and what a great week’s been – on several levels.

The first time I teach a newly written course – there are always things I can do better. There are the inevitable typos to correct, flow issues to work on etc. But as I de-stress from the long trip home, I reflect on the fact that it went well, the labs worked, well mostly, and the students had a great ride.

Whenever I teach ANY course, I have three objectives: to have fun, to learn more and to meet the students objectives. My view is that if we’re not having fun, not enjoying the week, then folks aren’t learning – which is NOT a good thing. Having fun and being (as the instructor) challenged is important. Meeting student expectations is vital, but having fun is cool too.

Well – this week I sure had fun. I had a great crowd of folks with varying skills who all wanted to learn more about V3. The folks were great – and being in Norway was fun. As to learning – man did I learn a bunch of stuff this week. And from the mails I’ve had the students all enjoyed the event. I even convinced one student to use Twitter – so hello @PowerShellGirl!

As part of the course, there are a number of VMs that we use  in the lab exercises. Rather than pre-build them, I had the students do the build. Using PowerShell of course. I have a nice set of simple build scripts that create a base VM image, and then create a primary DC, a secondary DC, and several member servers. As soon as I get a few hours to do it, I’ll publish these scripts – I’m sure they’ll be useful. I’ll also be improving the scripts to include installation of SQL, Exchange and a Certificate Authority.

Having scripts that create VMs has been a long term goal of mine. I so often need to create one or two (or more) VMs for use with an article/book etc. – building out a test infrastructure manually is so boring. The combination of PowerShell and Hyper-V make it relatively easy to create a lab environment that also shows students the real power of both Server 2012 and PowerShell V3. The more I work with Server 2012 (and PowerShell!) the more impressed I am with the potential.

Server 2012 is by far the best server OS Microsoft has ever produced. I just wish the idiot who insisted on the Windows 8 bi-polar interface was fired. Oh wait – has been! And that’s a good thing.  Of course, for a few dollars, I got Start8 which makes Sinofsky’s folly a dim memory. I can now get on and enjoy this truly magnificent OS.

Being able to show students how to manage the server using PowerShell is truly a joy. There is true beauty  in looking at many of the scripts I’ve put together for my course. I wonder if senior management really understand the true value of PowerShell? The power of many, the simplicity one  - it may be a marketing slogan, but it sure resonates for me. Being able to just invoke a script block on multiple machines in a couple of lines of script is just plain powerful – and very cool.

Well - 2013 is just around the corner and I am really looking forward to working more with both PowerShell V3 and Server 2012 in the coming year. As I write this blog, I’m listening to  Fleetwood Mac (Rumours) : “Don’t stop thinking about tomorrow – yesterday’s gone”   How apt the lyrics are. It’s been a great year – I’ve met some great people and now I have some great tools to work with. I just can’t stop thinking about tomorrow. 

Merry Christmas all – and may 2013 be a great year for you all.

Friday, November 23, 2012

Saving PowerPoint slides to PDF with PowerShell

Today, I’m having a bit of a catch-up day. One task I’ve been meaning to do for a while was to covert some PowerPoint slides to PDF for distribution and printing.

The basic task of converting a presentation to PDF is simple in PowerPoint. First you start PowerPoint and open the presentation. Then you save it as PDF using the Save-As dialog (and close PowerPoint).

The old saying if you have to do some thing more than once, write a script kicked in and so I did (write a script!). In theory, it should be relatively trivial to write a script that did just that. And once you know the complex PowerPoint object model, so it was! The full script is over on my scripts blog at: http://pshscripts.blogspot.co.uk/2012/11/convert-pptxtopdfps1.html.

It turns out that writing the script was a bit of a walk on the dark side, as in working with com and the Office COM objects. While what I wanted to do was simple, I needed to do it the way that PowerPoint's COM object wanted to – which was  bit different to working with some other API sets.

Working with Office, in particular the Office object model, from PowerShell is a bit painful. The PowerPoint object model is huge. When you instantiate the PowerPoint.Application object, you get a new object that is extremely rich and deep. You get loads of methods and properties. Many of these properties are themselves objects with methods properties (that can also be objects), etc., etc., etc. Since they are COM, the normal goodness of .NET reflection (i.e. Get-Member) is missing. Using a good search engine and applying a little ingenuity is the key!

In terms of getting this to work, the first issue I hit was the need to add some assemblies into PowerShell, like this:

Add-type -AssemblyName office -ErrorAction SilentlyContinue
Add-Type -AssemblyName microsoft.office.interop.powerpoint `
          -ErrorAction SilentlyContinue

Next, you open PowerPoint by instantiating the PowerPoint.Application COM object, and making it visible is relatively easy:

$ppt = new-object -com powerpoint.application
$ppt.visible = [Microsoft.Office.Core.MsoTriState]::msoTrue

An important point here is that you can’t use $True here to make PowerPoint visible. The ‘true’ you have to pass to PowerPoint is based on the enum, not on the normal .NET Boolean true. Finding these enums’s full name for PowerShell requires some Search Engine foo as the full class name is missing in the MSDN documentation.

Once you have PowerPoint open, you need to open the presentation and just save it as PDF. This is also easy, although you have to use the right enum (the string ‘pdf’ is not adequate):

$pres = $ppt.Presentations.Open($ifile)
$opt= [Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType]::ppSaveAsPDF
$pres.SaveAs($ofile,$opt)

In addition to the code here, you also need to clean up and close PowerPoint. You can see how to do that in the script on the PowerShell scripts blog

To test it, I ran this script (which is part of the script posted on the scripts blog!).

$ipath = "E:\SkyDrive\PowerShell V3 Geek Week\"

Foreach ($ifile in $(ls $ipath -Filter "*.pptx")) {
  # Build name of output file
  $pathname = split-path $ifile
  $filename = split-path $ifile -leaf
  $file     = $filename.split(".")[0]
  $ofile    = $pathname + $file + ".pdf"

  # Convert _this_ file to PDF
   Convert-PptxToPDF -ifile $ifile -OFile $ofile
}

So all things considered, it was relatively easy to create a script to do this conversion. And as this sort of thing is something I do all too often, this script will save me time in the future!

Technorati Tags:

Thursday, October 04, 2012

So You Need a Further Excuse to Book Onto The Next PowerCamp? DONE!

The next PowerShell PowerCamp event is coming up shortly and we’re rapidly selling out of places. The PowerCamp event is two fast-paced days looking at the basics of PowerShell V3 – I cover as much as I can over two days.

The PowerCamp event is primarily focused on those new to PowerShell but with plenty of depth for those with more skills. I’ve been running these for a couple of years and they are a lot of fun – both for me (I just LOVE talking about PowerShell – as any of my students will attest!!) and for the delegates who pick up a lot of useful skills and get to network with like-minded folk.

The next PowerCamp event, October 27-28 in London, is rapidly selling out – but if you are holding off, waiting for more reasons to book, you are in luck. Now to be honest, I think the two days of training is more than worth the fee, but I do try to add value and give you things to enjoy on the day and to take away.

So two important announcements:

First, those very nice people at Pluralsight are providing attendees with a free one-month trial membership to Pluralsight’s huge catalog of training material. Although Pluralsight is mainly a developer training company, there is a fair bit of cross over material – and I’ve published several PowerShell courses into their library already – and by the time PowerCamp rolls around, there will be an additional course, My Top-10 Coolest Features of PowerShell V3 with Windows 2012.

Second, those other very nice people at MVP Systems, attendees will get a nicer than normal Costa gift card for coffee – there’s a Costa Shop right outside the building where we are meeting. The PowerCamp event is being held in Microsoft’s Cardinal Place offices – and over the weekend there is no catering on site – but armed with your gift card, you can be sufficiently caffeinated! At least that’s the plan.

In addition to some truly great training (I had to say that!), some free coffee and a month’s free subscription to PluralSight, there will also be the traditional give-away memory stick with all the great PowerShell related goodies I can find and provide. And while I can’t announce anything yet, I am still working on a couple of more goodies for you to take away.

So if you want to learn more about PowerShell v3, AND get some cool goodies, sign up now – see http://tfl09.blogspot.co.uk/2012/08/announcing-powershell-v3.html for details on how to book. I hope to see you there!

 

Sunday, September 30, 2012

PowerShell v3 for Down-level OSs

As most of you probably know, the latest version of PowerShell, PowerShell v3, shipped inside Windows 8 and Server 2012 (including Server Core!). Microsoft has also released versions of PowerShell v3 for older versions of windows. Specifically, you can now download PowerShell v3 for:

  • Windows 7 – both 32-bit and 64-bit. You must have at Win7 SP1 loaded. (64-bit – 15.8MB, 32-bit 11.7MB))
  • Windows Server 2008 - both 32-bit and 64-bit. You must have at Server 2008 SP2 loaded . (64-bit - 14.4MB, 32-bit 10.5MB))
  • Windows Server 2008 R2 - 64-bit only and includes Server Core. You must have at Server 2008 R2 SP1 loaded 15.8MB)

If you’ve been running a beta version of PowerShell v3, then you have to remove it first before installing v3.

To get the various installation packages for your system, go to http://go.microsoft.com/fwlink/?LinkId=251995 (the Microsoft Download Centre) and look for Windows Management Framework 3.0. This package has PowerShell V3, and all the necessary plumbing (latest version of WSMan, some new cmdlets, etc, etc, etc.).

If you need to remove the WMF 3.0 package, you need to look for the KB article (KB2506143 for Windows 7 SP1 and Windows Server 2008 R2 SP1; KB2506146 - for Windows Server 2008 SP2)

There’s no excuse – get the latest version today!

Technorati Tags:

Thursday, September 27, 2012

Updated Start8 From StarDock

I see from email that StarDock has released an updated (beta) version of their Start8 utility that I wrote about recently. This neat little app puts the Start button back into Windows, meaning it’s easier to use (at least for some!).

When I last wrote about it, I got a lot of comments – as expected. Some of the comments, received in mail, on the blog and via twitter, were along the lines of ‘Windows 8 is different, get over it and learn it’  - something I can’t really rebut!  But I also got quite a lot of agreement as well as lots of cool tips on how to improve one’s experience with the Windows 8 UI. For all those comments, thanks.

It’s true that I can live without the start button and by using a combination of new keyboard sequences and pinning what I need to the desktop’s task bar (and ignoring the Start Screen) I can get by. BUT: why should I have to go to all that effort? If Microsoft had listened to folks like me, they would have given me the freedom and the opportunity to choose. It would have cost them nothing to have left the start button in the UI (if anything, ripping it out probably cost Msft more in engineering and testing than leaving it in would have cost). And it would have made the Windows team seem a bit less arrogant. But they didn’t and so I’m left with dealing with that. But anyway – if you are missing your start button – Start8 is a way to reclaim it. I like it and it, for me, makes Windows 8 a whole lot more attractive AND it makes me more productive.

One small thing – although in beta, Stardock have started charging for it. From their web site, the cost is US$4.99 or around £3.33. This is a sufficiently cheap price that I said yes in a flash.

And two final things: If you DO buy Start8, and want to save 10%, cite this discount code: RC-00017391. Second, thanks to John J Kavanagh, there’s an open source project that does much of what Start8 does – see http://http://classicshell.sourceforge.net/

Friday, September 21, 2012

Even More about Windows Server Core 2012 and GUIs

I’ve written a bit recently about Server Core in Server 2012. But here’s yet more details. In Server 2012, the GUI is an installable feature – one you can add or remove. There are actually three levels of GUI within Server 2012:
  • Full GUI – the full blown Windows Server GUI as we’ve always known it plus the Metro start panel, etc.
  • MinShell – a partial GUI but one that enables you to run things like Server Manager, some control panel applets,MMC consoles and PowerShell ISE.  But no desktop/Metro Shell and no IE.
  • None – The server core GUI as we love it – but with the opportunity to specify PowerShell as the window to open at boot (or when you RDP into it).
This provides a great compromise – you can have the GUI where you need it and remove it when you don’t. I love that – although not all applications will run on MinShell or Server Core itself. You need to check – but increasingly applications are server core friendly! For both MinShell and Server Core, the default is to run CMD.EXE as the default shell – when you logon to a server core box you see CMD.Exe. You can fix that easily enough so that at boot time you get PowerShell instead – a simple registry fix.
As part of the Launch of Server 2012 here in the UK next week, I’ll be presenting a bit on PowerShell and showing some of what it can do. One aspect of the server we are showing is Server Core and I’ll be demoing how easy it is – I wrote a script for that:
Function Set-GUI {  
[Cmdletbinding()]
Param(
[ValidateSet("Full", "MinShell", "None")]
[String] $GuiType = "Full"
)
# Here check what to do and do it Switch ($GuiType) { "Full"     { Add-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
             $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
             Remove-ItemProperty -Path $RegPath -Name Shell -ErrorAction SilentlyContinue –Force
           }
"MinShell" { Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra  # Just in case
             Add-WindowsFeature Server-Gui-Shell
             $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
             Set-ItemProperty -Path $RegPath -Name Shell -Value 'PowerShell.exe -noExit -Command "$psversiontable"'  -Force 
           }
"None"     { Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
             $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon" 
             Set-ItemProperty -Path $RegPath -Name Shell -Value 'PowerShell.exe -noExit -Command "$psversiontable"'  -Force  }
Default    {"$GuiType unknown - enter Full, MinShell or None"; return
           }
}
# Finally Reboot into new gui mode!
Restart-Computer
} # end of Set-GUI function
This could usefully have been added into the ServerCore Module!

Tuesday, September 18, 2012

Adding Keyboards in Server 2012 (and Windows 8)

In Server 2008 R2, you could use a control panel applet to add a new keyboard layout to your system – and for those of you whose normal UI-culture is other then EN-US, this is very useful. I have a very nice Microsoft Natural keyboard with a US layout. If I install an OS with En-Us, then I get the American keyboard just fine. Sadly, this means I can’t easily get to the £ and € characters. So I install a US-EN operating system, then use control panel to add a language (EN-GB) and then I have a nice task bar menu to enable me to select the one I want. As I touch type, moving between one keyboard layout and the other is pretty easy once I have both layouts loaded.

The only thing – Microsoft moved the place to configure my extra keyboard between Server 2008 R2 and Server 2012. In Server 2008 R2 (and Win 7), you use Control Panel and selecting Change keyboards or other input methods.

 

 image

 

This bring up the Region and Language dialog box, from which you click on Change Keyboards

image

 

This in turn brings up the Text Services and Input Languages dialog box. From here you click add to add a keyboard. The screen shot here is from a Server 2008 R2 computer with both US and UK keyboards loaded.

image

 

However, in Server 2012, Microsoft’s changed control panel and place where you add new keyboards. From Control Panel, you now select Add a language:

 

image

This brings up the Language Dialog box from which you can Add a language. The below screen shot is from a Windows 8 box with both keyboards loaded.  

 

image

So why did they change it? No idea – I suppose mainly because they could. But now you know where they hid that!

More on PowerShell on Server Core

PowerShell and Server Core – Server 2008 R2 and 2012

in July, I wrote a few articles on PowerShell in Server core (here, here, and here). There were two key points noted in those articles. First, Server Core in Server 2012 has a removable GUI – you can add it or remove it! Secondly, in Server Core in Server 2012, by default, the system starts up running CMD.EXE, not PowerShell, although there’s a simple registry hack that enables you to run PowerShell instead.I’ve been playing with this a bit and have discovered a few additional things about Server Core and PowerShell.

Adding PowerShell v3 to Server 2008 R2 Server Core

The first interesting thing I’ve found is that you can add PowerShell V3 to Server 2008 R2 Server Core. However, to do that, you need to add the .NET Framework 4.0 to your server core system. Go to the Microsoft Download centre and download the Microsoft .NET Framework 4 (Standalone Installer for Server Core. Your Server Core installation needs to be running SP1 or higher. Read the instructions carefully!

Adding GUI to Server Core – Which Shell to Run

In one recent article, I noted how you could add and remove the GUI from Server Core. I’ve written two functions (Enable-GUI and Disable-GUI) that convert between the two GUI modes. I’ve tested these functions pretty thoroughly and the adding and removing of the GUI is straightforward, albeit on the slow side.

One thing I found is that if I first set PowerShell as the default shell (see here), then add the GUI, when Windows Server 2012 restarts, you have the GUI, but the shell itself doesn’t start – PowerShell runs as the default shell!  It took me a few minutes to work out what was going on. A very simple workaround is to remove the Shell default value from the Registry before rebooting. The code to add the full GUI back to Server core now looks like this:

Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra -Source d:\sources\sxs
$RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
Remove-ItemProperty -Confirm -Path $RegPath -Name Shell -ErrorAction SilentlyContinue

To get the full scripts see here (for Enable-GUI) and here (Disable-GUI).

Sunday, September 09, 2012

PowerShell PowerCamp October 27-28th–Filling up and a Special Guest!

Now that folks are back to work and catching up on their reading, I’m starting to get bookings for the October PowerShell PowerCamp event (http://tfl09.blogspot.co.uk/2012/08/announcing-powershell-v3.html for the details). It’s great to get mail from folks asking for a place – so far the farthest away is from New York City. Very Cool!

As those who have come on earlier events know, I try to have an extra guest to come along and offer some additional thoughts on how to best use PowerShell. I give them leeway to talk about whatever they want – past events have seen James O’Neil and Tom Arbuthnot provide some thought provoking insights. In October, I’m very pleased to announce that we’ll have Richard Siddaway. Richard is a well published PowerShell author and an MVP.

So if you are looking for a fast paced, fun filled introduction to PowerShell, this is an event for you. I hope to see you there to continue your journey into the joys and delights of Windows PowerShell v3.

Saturday, September 01, 2012

Start8 – Get the Start Button On Windows 8

Like many users of Windows 8, I really dislike what some call its bi-polar User Interface – the appalling (IMHO) start screen combined with the partially neutered desktop. And don’t get me started on how lame I think most of the Metro (SIC) applications are? We had a better UI than this in Windows 2! Why can’t I just overlap Metro (SIC) apps? Why can’t I have 3, 4 or more all up on the screen at once?  The same sentiment occurs on Server 2012, although on Server 2012, I’m well served with PowerShell!

Despite all the other goodness that is inside Windows 8, I find this UI poor. It really makes me dislike Windows 8, and (to use the language of all the Msft surveys I seem to get!), it does not make me feel better about Microsoft. Now, I am sure that a) many people love this new UI and b) it will be great on a tablet or phone. But for me, this dual-purpose UI is just plain a waste of space on corporate desktop PCs that, by and large,  continue to be used by knowledge workers using desktop applications – even Office vNext is not a Metro app (well not yet anyway). 

I have two great big 24-inch TFT panels that are not touch sensitive. Initially, using both Windows 8 betas and Server 2012 betas, I found myself constantly flipping back and forth between the desktop and the start screen. This was slow and very painful – and made me put Windows 7 back onto one of my desktop machines.  From the press coverage of Windows 8, I know I’m not alone! Although public opinion is not totally on my side, it’s pretty heavily weighed that way! All in all, Microsoft could have, and should have, done better.

Imagine my delight and excitement when I came across Start8, a new application from StarDock. Simply put: this application puts the start button back into Windows 8. It also changes the startup process so that instead of dropping you onto the Metro (SIC) Start screen at boot time, you are put straight into the Desktop. And there’s even a ‘start/run’ box on the Start menu! This is what, IMHO, Windows 8 really should have looked like: It lets me use Metro and Metro apps when that is appropriate (maybe if I get a Surface), but not have the start screen in my face quite so much. And on desktops and laptops, I get the best out of Windows 8 using a familiar and easier to use UI! I have converted my laptop to Windows 8 and with Stat8, I am enjoying the new OS.

Here’s what it looks like in one of my Windows 8 VMs.

image

 

Notice the nice shiny start button just where it used to be?  Well – when you click it, you see:

image

 

 

And as a really cool added feature, if you right click that button, you get to shut down the system – which looks like this:

image

Now, with the start screen (and the metro apps that come with it) are not so in my face, all that awful stuff I hated about Win8 is now largely a memory. On my main Win8 box (my laptop!), I’ve installed my favorite browser and music player, and now spend almost all my time on the desktop using desktop applications. And being productive!

For me, this has transformed my view of Windows 8. Instead of fighting the UI every time I try to use it, I now can be productive, and enjoy all the truly great features of Windows 8. With Start8. I now really enjoy using Windows 8. I have even recommended it to some of my friends working at a large software giant who agree with my views on the UI (even if they probably can’t be seen being productive and using it).

Right now, whilst it’s in beta, Start8 is free. But I like it sufficiently, I’m happy to buy it when it is finally released. This product makes Win8 usable for me and as long as Microsoft feel they know better about what my PC should look like, it’s going to stay on my Windows 8 and Server 2012 desktops.

My overriding question is: if an ISV like Stardock could do this and make it look so good, why couldn’t Microsoft?

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

PowerDrinks?
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 http://tfl09.blogspot.com and PowerShell Scripts Blog at http://pshscripts.blogspot.com).

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 DoctorDNS@Gmail.com 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:

image

Clicking Activate brings  up this message:

image

 

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

 

image

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:

 

image

 

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.

image

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):

image

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

image

 

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.

[Later]

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:

Friday, July 06, 2012

More on PowerShell as the Default Shell in Server Core 2012

Yesterday, I posted an article showing how easy it was/is to change your default shell inside Windows Server 2012’s Server Core installation option, and I’ve been playing around with it a bit more. I also noticed Paul Gregory’s blog post on the subject.

The shell that Windows Server 2012 uses to determine which shell to run is at: Hklm:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon" in the Shell item property.  In Server 2012, this is set, by default, to Explorer.exe. I’m still not quite sure how Explorer knows to load CMD.exe, but it seems to!

To change the shell is simple – just run a variation on: Set-ItemProperty -Path $RegPath -Name Shell -Value 'PowerShell.exe'.

By some variation – I mean you can, in the value entry, specify parameters to PowerShell at startup. If you just want a plain old shell, with all 4 profile files attempted, then leaving the Shell value to just “PowerShell.exe” is fine. But here are some other parameters you could also specify:

  • -MTA, –STA – you can specify to always start up PowerShell in a single threaded or multithreaded apartment. –STA is the default, but if you always need an MTA on a given server, you can.
  • -PSConsoleFile – you can create a console by configuring PowerShell the way you want it to run, then use Export-Console. This might be useful on a single function server to pre-load specific modules, but you’d need to work out how to manage the exported console (where do you put it, how do you update it, etc).
  • -NoProfile – speeds up startup, and is arguably a tad safer. You could theoretically get your profiles ‘infected’ – this option avoids such malware running.
  • -EncodedCommand – accepts a base-64 encoded string – useful if you have to pass a command to PowerShell that requires complex quoting, and use of braces ({}).
  • -Command, –NoExit – you can get PowerShell to run a command, over and above the profile files by specifiying the Command parameter. If you use the Command parameter, you should also specify –NoExit to avoid PowerShell from running the command and immediately exiting!
  • -Version – starts a specific version of PowerShell. This is useful to get PowerShell to start up in V2 on Server 2012, where V3 would of course be the default.

There are a few more parameters, but those are the key ones.

 

Thursday, July 05, 2012

Making PowerShell the Default Shell in Server 2012 Server Core

Server Core, in Windows Server 2012, is a much improved version of this installation option, first introduced in Windows Server 2008. At the time Server Core was first introduced, it made sense to make CMD.EXE the default shell. Heck – PowerShell could not even run in that environment. But times move on and in Windows Server 2012, Microsoft install PowerShell by default in Server Core. But the legacy of CMD.EXE still remains – at least by default
.
Turns out it’s just a registry setting to tell Winlogon what shell to start-up at boot time. Thanks to a post by Jeff Hicks, I knew where in the registry the key was, and thanks to James O’Neill, I knew what to put in the value! Setting it is then remarkably easy:

$RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
Set-ItemProperty -Confirm  -Path $RegPath -Name Shell -Value 'PowerShell.exe -noExit -Command "$psversiontable'
Restart-Computer

After rebooting – you have PowerShell as your default shell in Server Core. If you are brave, you could just even the –Confirm from the Set-ItemProperty!

Adding (and removing) the GUI From Server Core in Server 2012

One (of the very many!) neat feature of Server Core inside Windows Server 2012 is the ability to add/remote the GUI. This is a feature I wanted since Microsoft first brought out Server Core.  To add or remove the GUI in Server Core, you need to run a cmdlet from the DISM module. To Add the GUI to Server core:
Enable-WindowsOptionalFeature –Online –NoRestart `
  -Featurename ServerCore-FullServer,Server-Gui-Shell,Server-Gui-Mgmt 
Removing the GUI is equally as simple:
Disable-WindowsOptionalFeature –Online -NoRestart `  
  -Featurename ServerCore-FullServer, Server-Gui-Shell,Server-Gui-Mgmt 
I’ve written a couple of functions that do this for you – posted over on my PowerShell Scripts blog.
This is pretty cool – and it works incredibly easily. This allows you to install a server core machine, add the GUI for initial setup or subsequent troubleshooting but then easily remove it for production running. Another GREAT Server 2012 Feature enabled with PowerShell!!

[Later]
Thanks to Scott R for noting a typo in this post - now fixed!

Tuesday, July 03, 2012

Even PowerShell knows the Way Forward

Came across an interesting PowerShell code fragment recently:
image
Nice to know PowerShell has your back.

Saturday, June 30, 2012

Playing with Windows 2012 Multi-Computer Configuration options

I’m doing some editing of an upcoming course on Windows Server 2012. One key feature of the course is showing off multi-computer management. As part of that, I’ve rebuilt a pair of Windows 2010 RC servers. I plan to run VMs on both machines, but also to manage the pair using PowerShell and the new Server Management tool. The new Server Manger now resembles this screenshot taken from one of my new hyper-V hosts:

 

image

As you can see, I’ve defined two new server groups, HyperV Guests and HyperV Hosts. This tool makes it possible to mange groups of servers as a single entity. Under the hood, things get really cool. When you carry out remote management using Server Manager, Server Manager creates a PowerShell Workflow to carry out the management task, and then executes it against the remote  servers. But I can also do this directly from PowerShell (with our without the workflow aspect).

For example, suppose I want to add all the RSAT tools to both HyperV hosts: Well I could do it from the GUI, but from PowerShell, this is trivial:

Invoke-Command –ScriptBlock {Get-WindowsFeature –Name *rsat* | Add-WindowsFeature} –Computer Cookham11,Cookham12

And just like that, all the RSAT tools got loaded on both machines. This is extremely powerful but to really make use of it, you have to start thinking a bit differently and get to know and love PowerShell remoting.

Technorati Tags: ,

Wednesday, May 02, 2012

Another Fine PowerShell PowerCamp Weekend–Sadly All Over!

The weekend of April 21/22, 18 hearty IT Pros and I spend two days looking into PowerShell. A jump start look at all the key aspects of Windows PowerShell. The event focused on the core aspects of PowerShell – Cmdlets, the Pipeline, Objects, and Remoting. We we also reviewed the the PowerShell language as well as the cmdlets that have been added into Windows Server 2008 R2/Win8.

The attendees came from all walks of (IT Pro!) life, but all shared an interest in really learning more about PowerShell. The event only lasts 2 days and there is an obvious limit of how much anyone can absorb without brain overload creeping in. A key focus of all the modules was discovery – how the attendees can figure out stuff for themselves, and leveraging the community. 

It was a great weekend and I still have some admin to do around it. I am currently looking into a further PowerCamp in the autumn – during October if possible.

And a big thanks to Idera, MVP Systems and Quest – all of whom kindly provided some goodies I could provide to the delegates. Much appreciated.

Technorati Tags: ,

Thursday, April 26, 2012

Lync for Macintosh–update released

Microsoft has released an update for the Lync client for Mac. This update fixes the following:

  • Several issues with Cisco and Juniper VPN clients
  • An issue that causes an Active Directory lockout when the Kerberos protocol is used
  • Several issues that cause Lync for Mac 2011 to sign out unexpectedly or to crash

Microsoft recommendl all Lync users on Mac install the update. You can find more information at: http://support.microsoft.com/kb/2690036:

Monday, April 16, 2012

PowerShell Weekend PowerCamp–Coming very soon

As many of you know, I’ve long been an advocate of all IT Pros (and devs!) learning more about PowerShell. There are a lot of ways to do this, and one great way is to attend a short (read 2 day at the weekend), jump start events. And as it happens, there’s one coming up soon.

This weekend coming, April 21-22, I’m holding the latest PowerShell PowerCamp, a weekend PowerShell jumpstart training event. We’re holding the event at Microsoft’s London offices in Cardinal Place Victoria from 9:00 till 5:00 – two long days of PowerShell, PowerShell, and more PowerShell.

The details of the agenda remain as I first published them back in January. There’s still a couple of places should you fancy the opportunity to learn more about PowerShell, so if you fancy it, let me know by emailing DoctorDNS@Gmail.Com and I’ll take it from there.

Technorati Tags: ,

Sunday, April 08, 2012

PowerShell Scripting Games–Halfway Complete!

If you are a PowerShell Junkie, you know that the PowerShell Scripting Games began last Monday, and the first five events, in each category, are now posted and are being judged. If you are not a PowerShell junkie, the PowerShell Scripting Games is an annual competition amongst beginner and expert scripters to show off their scripting skills (or to learn more!). I described this in my blog last week (http://tfl09.blogspot.co.uk/2012/04/2010-powershell-scripting-games-begins.html). For a more light-hearted introduction, see Sean’s We Will Script It:

 

We Will Script IT!

The Scripting Games are a time for YOU to both show off your skills, and to lean more. For the judges, it’s turned into quite a lot of work, and a learning opportunity too!

The number of entries, so far, way exceeds my expectations. As of today, here is the count of entries:

image

If you are good at counting, or can use PowerShell to do the maths – this is tallies to just under 1500 scripts entered so far – and we’re only half way through the overall event. WOW!  I certainly did not expect anywhere near so many entries!!! This just goes to show the momentum and traction that PowerShell is getting.  But it’s sure ended up being a lot of work for the judges – having to review every script and mark it. I had hoped that this year, I’d be able to rate every script, but so far, I’m way behind – I’ve rated probably not much more than 500 so far, and given my real life job, may get further behind as the week goes on! What a really nice problem to have.  I may not end up rating ALL the scripts, but I’ll do my best.

In judging the entries so far, there are several things I’ve noticed:

  1. Some folks can’t read very well or type well. Sad smile There have been far too many scripts entered for the wrong event - if you are entering Beginner Event 1, then please don’t submit the script for Advanced Event 1 or any other event! Also, some folks are not reading the specific details that the script is meant to deal with. While some of the solutions are great, they are not ones that meet the criteria of the event(s).
  2. Handling of Boolean values is not well understood. If you have a Boolean value in PowerShell (eg $Foo), then checking true/false in an If statement should look like this:

       If ($Foo) { <action if true>} else {<action if false>}

    and NOT this:
  3.     If ($Foo – eq “true”) { <action if true>} else {<action if false>}

    Strictly speaking, testing $foo against ‘True’, $true (and $false) works, but the explicit test is unnecessary. And if you are testing against a false value, $foo –eq “false” returns false, NOT TRUE!  I intend to cover boolean values more in the upcoming PowerCamp!

  4. Live vs Static Objects – some objects, when created, are filled with property values that never change (until you refresh the objects). Other objects do update some properties but this is not universal. The System.Diagnostics.Process class is one that a) does some automatic refreshing of property values and b) has a .Refresh() method that refreshes the value. Calling .Refresh is a little faster than creating the whole object. And hands up – I did not know about the .Refresh() method  prior to this year’s competition!
  5. Comment, comment, comment. I see lots of script without any comments, either in the script or in the comments on the solution. If you make a mistake with syntax, the comments might save you a point!
  6. There are a lot of new folks out there who have got the message (PowerShell is the future) and are going great guns to prove their skills. Thanks for your time and effort and even though the scores may not show it – you’re all winners!!

And while thinking about it – see Ed Wilson’s comments on the Games so far at: http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/07/six-observations-about-2012-scripting-games-early-entries.aspx.

So far, this has been a pretty cool competition, and it’s taught me a few things already. If you have not yet joined in, there’s always time to do a few entries. And remember, it’s taking part that counts, not whether you win or lose – everyone’s a winner here!!

And finally – if you are looking at the Events, wondering a) how to solve them and b) feeling like you SHOULD know(!!), and you live in the UK, consider coming along to the PowerShell PowerCamp weekend – we’ll be covering some if not all of the event scenarios during the weekend so who knows, attendance at PowerCamp could mean you are next year’s winner.

Monday, April 02, 2012

2012 PowerShell Scripting Games Begins Today!

As many PowerShell fans know, today sees the beginning of Microsoft's PowerShell Scripting Games. The Scripting Games are a set of 10 PowerShell challenges in two classes (Beginner and Expert). The idea is simple: you sign up for either of the classes and each day for 10 days you get a scripting challenge involving writing a PowerShell Script. After solving the challenge and writing your script, you submit it to Poshcode.Org. Once submitted, a stellar panel of judges review it and each script gets up to 5 points. At the end of the Games, the folks with the highest scores win prizes. Easy!

Each individual event is to be posted at noon Seattle time (i.e. 20:00 here in the UK). So consider this a bit of homework! Once posted, you have 7 days to submit an answer. Once submitted, your script gets judged by the distinguished panel of judges based upon a set of judging criteria. You should read these criteria as they can affect the score your submissions receive.

To see all the links for the Games, visit here. This has pointers to how to register, details of the judges, and everything you need to know about the games. For each contest, you’ll also get a Guest Commentary from someone in the PowerShell community looing at how they would go about solving the problem. Speaking for myself, I look forward to reading both the scripts entered by the competitors AND to the guest commentaries. I am sure to learn something – it happens every year!!

So if you think you have good PowerShell skills, or if you just want to learn more – come on down, enter and enjoy the contest!

Technorati Tags: ,

Wednesday, March 21, 2012

Finding The Folder the .NET Utilities Live in - Using PowerShell

I am playing around with some PowerShell V3 stuff and needed to use Ngen.exe to do a native generation of an assembly and move it to the Global Assembly Cache. So where is it? I could have wandered around in the Windows folder, but instead decided to ask .NET itself, using PowerShell.

The .NET class System.Runtime.InteropServices.RuntimeEnvironment contains several static methods that return information about the CLR environment.  There are three that are of possible interest to the IT Pro:

FromGlobalAccessCache – this static method tests an assembly to determine if it ewas loaded from the GAC.

GetRuntimeDirectory – this static method returns the folder name where the CLR was installed. This folder contains Ngen, the C# complier, and other .NET tools.

GetSystemVersion – this method returns the version number of the .NET Framework

 

From PowerShell Version 2, this looks like:

 

image

If you are using the beta version of PowerShell V3, you might see this:

image

File under: Interesting things you can do with .NET and PowerShell.

Wednesday, March 07, 2012

PowerShell Version 3–Updatable Help (continued)

In a recent blog article I discussed the new updatable help feature of PowerShell V3. In that post I described the Update-Help cmdlet and shows how you use that cmdlet to up date your help information. The Update-Help cmdlet knows how to go online to find, download and install updated help information for both the core PowerShell modules plus any additional modules on your system. The PowerShell V3 module feature enables Get-Help to know (or be told!) where to look for updated material for each module, and does what is needed!

But what if you are offline, or you are in an air-gap network, isolated from the Internet. Well, obviously, in that situation, Update-Help can not go online and get the necessary updates. But PowerShell does provide a cmdlet, Save-Help, that can get the necessary help information and can store it. You can then copy somewhere Update-Help can then find – in the case of an airgap network, you could copy the help information to a memory stick, then use sneaker-ware to copy that material onto the airgap network.  Let’s take a look at both these aspects.

To save the help files, you use Save-Help, specifying a destination path (where you want the files saved). Optionally, you can specify the UI culture for which you want to get updated help. Specifying the –Verbose switch provides more output describing what Save-Help is doing. By default, you can run Save-Help or Update-Help just once per day (per machine). To over ride this, use the –force parameter.

Here’s what Save-Help looks like in my Windows 7 workstation:

 

SNAGHTML1f74f896

As you can see from this screenshot, PowerShell gets the files and stores them in the path folder, which then looks like this:

SNAGHTML1f79c392

Each PowerShell module has the two files that make up the extensible help for that module:

  • An XML file – this identifies the UI version of the help content (found in the XML).
  • A cab file – containing updated MAML and about_* files. Each file in the cab file represents something to be moved (later) by update help.

Each pair of files is named using a simple naming convention of : <module name>_<module guid>_<ui culture>_<helpinfotype, where <helpinfotype> is either HelpContent (in which case the file has a .CAB extension), or HelpInfo (in which case the file has a .XML extension).

You will notice that when I got the help, Save-Help could not find help for the module TFL. That’s mainly because that help information has not yet been written and saved in EN-US locale (well, not yet anyway!). I will do another blog post at some point where I explain how to add updatable help to your module.

To install this help on the air-gap network or machine, or one you want to update offline, you first have to save the files to somewhere you can later access them from the network/machine. As I suggest above, a USB memory stick can be used to transport them (or CD, etc). Once you have the files moved to their appropriate place, you use Update-Help, specifying the SourcePath parameter and providing the path to where the help files are available. The update would look something like this:

SNAGHTML1f8d8193

The Update-Help cmdlet (when verbose is specified), displays the XML files parsed and whether or not the associated HelpInfo file was processed and the help files in the CAB file that have been moved to their appropriate location.

 

Technorati Tags: ,,