Extending PowerShell – Notes from my 4/26 Presentation

This past Tuesday, I was privileged to speak at the Cleveland C#/VB.NET SIG on extending PowerShell. Since I knew that my audience wasn’t necessarily familiar with PowerShell (except a few), I spent the first half of the session introducing PowerShell and many of its key concepts with the help of a custom module, built specifically for this presentation.

The only PowerPoint slides that were used were Sam’s slides to announce upcoming user group meetings, events, and sponsor information. Otherwise, I chose not to use PowerPoint and took a page from my friend Matt Casto‘s book, using a technology to present the technology. (He had done a presentation on Silverlight at a Central Ohio Day of .NET using a Silverlight app to show “slides”. I thought this was a cool technique and figured I could use PowerShell to explain PowerShell.)

The custom module is a manifest module, as I generated a PSD1 file for the module. However, if you remove the PSD1 file, the module is then considered to be a script module, as was covered in the talk.

To give you some background, my $profile has the following setup:

Set-Alias alias Set-Alias

function Get-Home{
    cd ~

$PSModulePath = $env:psmodulepath

I use the alias example because it irritates me to no end that there are some Linux commands that are already aliased, but the obvious alias alias was left out.

The function Get-Home is referenced in one of my help files. There’s a story behind this one. Again, this goes back to my Linux/Unix background. While Matt and I were working on the book, he had an example of a custom function that would get the user’s home directory. He used some long, convoluted path after the cd command. Of course, I had to come back and explain to him what the ~ meant, as I used to type cd ~ a lot when I spent time in the Unix labs on campus in my college days. It wouldn’t be until later on, as I was preparing for this talk, that I found the ~ explained in a PowerShell help file. (It’s in the help text for Resolve-Path.)

Finally, I included the $PSModulePath variable for two reasons. One, there’s improper documentation that this variable is a pre-defined variable. There are community comments that point out this flaw. The other reason is so that I can use the environment variables as a good segue into the providers topic.

I noted that I was not really going to get into covering creating custom providers, as there is a lot of detail behind that. However, if you want to talk providers, Oisin Grehan is a PowerShell provider master. He is also the guy behind the PowerShell Script Provider, to allow writing PowerShell providers in PowerShell scripting language and not necessarily in C#.

The other recommendation that was mentioned was to use the #PowerShell hashtag on Twitter, as there are many awesome PowerShell MVPs and notable people who work with it who are gratiously answering questions and helping as needed, providing direction for learning more on PowerShell.

You can download the custom ClevSIG2011 module here.

If you have PowerShell already installed, then here are the steps for using the module:
1. Extract the zip file into one of the Modules folders in $env:PSModulePath. Since this is unique to me, I put mine in my DocumentsWindowsPowerShellModules folder.
2. Start PowerShell (ISE or console).
3. Run the following command: Import-Module ClevSIG2011
4. Getting started with the module, run: Get-Help about_KeyTerms for more information.

The second half of my presentation involved creating custom cmdlets. In our book, I wrote about cmdlets to work with the Windows 7 Libraries feature – the feature that deals with Documents, Music, Video, Pictures, Contacts, and Downloads. The code that I used for that part will most likely be included in supplemental materials for our book. You can pre-order the Automating Microsoft® Windows Server 2008 R2 Administration with Windows® PowerShell 2.0 book through a variety of vendors.

I had a lot of fun presenting to such a lively crowd, and I especially enjoyed talking with others at Mavis Winkle’s afterwards! Thanks to all who came out for it!

Taking Advantage of Book Deals…

While scouring the Internet to see just how much the PowerShell book costs, I found some cool deals that I wanted to share with you…


Amazon deal - Pre-order both "Automating with PowerShell 2.0" titles at $60.15

The Automating Active Directory Administration with Windows PowerShell 2.0 title focuses in depth on Active Directory. This book was written by Ken St. Cyr, an architect at Microsoft who specializes on identity management and Exchange, and Laura E. Hunter, a Microsoft IT ADFS & IdM architect. If you’re getting started with PowerShell, buy our book, and if you’re in an environment that relies on Active Directory, then get their book too! Why pay full cost for both when Amazon is running such a great deal?


Save 20% when you buy both of Matt's books!

For those of you who are working with Windows Server 2008 R2, take advantage of the deal that Wiley is running, where you can get our PowerShell book and you can also get my awesome coauthor Matt Hester‘s other book Microsoft Windows Server 2008 R2 Administration Instant Reference. Both of these books are great to have on hand as references while administering the Windows Server 2008 R2 environment. Use Matt’s first book as a guide for everything in Windows Server 2008 R2, and use our PowerShell book to script a lot of those processes and make life a lot easier!

I’ve linked the images to the pages where I found them in the first place. Take advantage of these deals while they last!

Announcing the Official Release Date for my Book!

As I’ve mentioned before, I’ve spent quite a bit of time these past few months “wrediting” – writing and editing – a book on Windows PowerShell 2.0 and automating Microsoft Windows Server 2008 R2. While the book focuses on some of the great new features of R2 and PowerShell 2.0, it also focuses on fundamentals. This book is great for those who want to get into using the new features without getting too deep into the language. Even with the appendices, I tried to keep it simple so that those developers just getting into it have a simple guideline to follow.

I just got word from my acquistions editor that the official release date is May 16th, 2011. You can pre-order it from many retailers – including Amazon, Books-A-Million, Barnes & Noble, Borders, Indie Bound, and of course through the publishing house of Wiley.

Here’s the cover to look for:
Automating Microsoft Windows Server 2008 R2 with Windows PowerShell 2.0

I’ve mentioned my book a bit before. You can read more about it in:

Matt and I will share some insight into the book in a series of blog posts coming in the future. So look forward to hearing more about our book!

Whatcha talkin’ about? April Edition

Now that the book is mostly finished, I have some free time again, which means I’m back in the community!  This month, I’ve got two speaking engagements that I’m really looking forward to – one on PowerShell and one on code sharing across platforms.

Cleveland C#/VB.NET SIG  – Tuesday, April 26th, 6:30pm – 8:30pm

This month, I’ll be speaking on PowerShell and specifically how it relates to developers.  Since many developers may have only heard of PowerShell in passing, I’ll briefly give an intro to what the language is, what it looks like, and why a developer would be interested in it.  The rest of the presentation will focus on the developer side of things – how to write custom cmdlets and modules and possibly touch on providers, if time allows.

Pittsburgh Code Camp 2011.1 – Saturday, April 30th

I also received confirmation that I’ll be speaking at Pittsburgh Code Camp.  This time, I’ll be delivering my talk on developing code for 3 Windows platforms – Browser, Desktop, and Phone.  This will cover some tips and tricks for writing minimal code to work across all three platforms.

I hope to see some of you at these events!