Articles

PowerShell articles, tutorials, and guides from community experts.

Don Jones

Upcoming PowerShell Books and How to Get Them

My co-authors and I have no less than three new PowerShell books coming out… and a couple of different way to get them.

PowerShell In Depth

This is meant to be a comprehensive, administrator-focused reference on all things PowerShell v3. It’s available directly from the publisher as part of their Manning Early Access Program (MEAP). Under that program, you get all available chapters now in PDF format. As new chapters are released, you get those too. When the book is done, you get your choice of ebook format and, optionally, the printed book.

Don Jones

[UPDATED] Snover School: FANCY Wildcards

So, I’d previously posted about a cool trick Jeffrey Snover demonstrated at TechEd:

Get-Service -Name [a-b]*

This will return a list of all services whose names start with A or B. Now for me, this was a cool trick: I didn’t realize that wildcards could be more than * or ?! And Snover described these as “rich regular expressions.”

Well, not exactly. We’ve corresponded, and what’s actually happening is that PowerShell’s wildcard support is essentially a dumbed-down set of the regex syntax. Specifically, read the about_wildcards help topic and you’ll learn that you can use ranges like [a-b], the * and ? characters, or a set of characters like [abeft] - but not much else. So it looks like a regex at first blush, but isn’t, really.

Don Jones

TechEd PowerShell Sessions

Many sessions are now available on Channel 9 as recordings…

First, mine:

But wait, there’s more!

- 
  [App-V 5 and PowerShell](http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/WCL201)


- 
  [Win2012 Multi-Server Management](http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/WSV306)


- 
  [Advanced Automation in PSH 3](http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/WSV414)







I'll caution you that the videos haven't yet been posted on all of these, so poke around until you find 'em all. With hundreds of sessions to sort through, I imagine they're prioritizing the production process. 

Don Jones

How To Use Write-Host Without Endangering Puppies (or, A Manifesto for Modularizing PowerShell Scripts)

At this week’s TechEd, I was speaking with Jeffrey Snover in the hallway on Wednesday when he remarked, “you know, Write-Host isn’t all bad.” After he got someone to come around with smelling salts to revive me, he elaborated, “so long as your verb is Show.” I started to object - and then a subtle, yet brilliant light came upon me.

He’s write. Heh.

But, seriously, if you do three simple things, you can’t go wrong when you write a PowerShell script or function - and this goes further than just Write-Host. Ask yourself:

Don Jones

Sample Code from my TechEd "Building Reusable PowerShell Tools" Session

Hey, all! I was looking over the script I’d saved from this TechEd session, and realized I could offer something better.

Go to the Web page for my upcoming “Toolmaking” book. In the Downloads section, grab the book’s code samples. You’ll actually get a better example than I showed in class, and it goes further. The listings for Chapter 13 pretty much put you where that session wraps up.

Now, these haven’t been totally tech-edited yet, so if you find any bugs - please let me know! The book itself should go into “Early Access Preview” in a couple of months, I’m hoping. Stay tuned!

Don Jones

Using PowerShell to Scrape the Web

One of the things administrators often look to do with PowerShell is “scrape” Web pages. In the past, you had a couple of options: Use Internet Explorer’s COM object (which can get a bit fugly), or use the .NET Framework’s WebRequest stuff (slightly less fugly, but still a bit).

PowerShell v3 to the rescue. Microsoft has wrapped much of the fugly in some cool and simple cmdlets, and given PowerShell a native ability to understand an HTML document’s object model (DOM). Note that the ability to parse the HTML document tree is dependent upon IE being installed, which means it won’t work on a Server Core system (since IE doesn’t exist there). You’ll still get some HTML parsing, but it won’t be the full, broken-down tree.

Don Jones

[UPDATED] Tweaks to PowerShel v3 Updatable Help

I’ve written before about how PowerShell v3 won’t come with help “in the box,” but will instead require you to download help from Microsoft’s servers.

ASIDE: Technically, any module author can provide updatable help on their own Web server; you just have to tag your module manifest with the appropriate information so that PowerShell can locate your online content and download it.

Now that Windows PowerShell v3 Release Candidate is out, I’ve noticed a slight tweak to the help system. Previously, if you looked at a command’s help prior to downloading the help content, you still got the basic syntax and a reminder that you hadn’t yet downloaded help. That still occurs, but when you first try to ask for help (if you haven’t downloaded it), you actually get an interaction-required Yes/No prompt, reminding you to run Update-Help to get the help content to your computer.

Don Jones

FInal Outlines for the v3 "Lunches" Books

1
1095
6247
Concentrated Technology
52
14
7328
14.0
Normal

false
false
false
EN-US
JA
X-NONE

I wanted to get these posted for folks’ reference. The books are proceeding apace, and now that PowerShell v3 is in Release Candidate, we’re going to move forward with publication ASAP.

ToC – “Learn Windows PowerShell 3 in a Month of Lunches”

Before You Begin

a.
Why You Can’t Afford to Ignore PowerShell

Don Jones

Looking for a good tech conference? Try this.

It’s called TechMentor. The next one is in August, at Microsoft campus. Yup, in Redmond. The mothership. And, unlike larger shows (like TechEd), you won’t be one of 15,000 people crammed into a convention center, fighting for lunch space and getting ignored by speakers. TechMentor’s a more “boutique” event, with just a few hundred other IT professionals (and no developers - ew, cooties!). You’ll get tons of one-on-one time with expert speakers (like me), and plenty of networking time with your colleagues. And smaller lines for lunches.

Keith Hill

PowerShell V3 "“ ObsoleteAttribute

PowerShell V3 now supports the ObsoleteAttribute for compiled cmdlets but unfortunately not advanced functions. This is handy to let your users know that a binary cmdlet will be going away in a future release of your binary module.

As we work on PSCX 3.0 there are a few binary cmdlets that we will mark with this attribute to let you know to switch over to PowerShell"™s built-in equivalent before we eliminate the cmdlet completely in the next release. Here"™s a snippet that shows how to apply the ObsoleteAttribute in your source code: