Articles

PowerShell articles, tutorials, and guides from community experts.

Don Jones
PowerShell for Admins

How Cloud-First Design Affects You

Today, Brad Anderson (Corporate VP in the Windows Server/System Center unit) posted the first in what should be a series of “What’s New in 2012 R2” articles. In it, Anderson focuses on how Microsoft squeezed so many features into the 2012R2 release in such a short period of time. The short answer, which has been stated by Jeffrey Snover before, is “we build for the cloud first.” That means features we’re getting in 2012R2 have, for the most part, already been developed, deployed, and in use in some of Microsoft’s own cloud services. This is a huge deal. It means their cloud services (think Azure, O365, and the like) get stuff first, where Microsoft can make sure it’s stable. They then package those and hand them off to us.
It means we get better stability, but it also means we get better manageability. Look, you don’t get excited when you have to deploy a new server, right? You want to automate that stuff. Well, Azure gets really ticked off if they can’t automate it, because they do it thousands times more than you. So forcing themselves to run a ginormous datacenter also forces the company to make better management tools - which they then hand down to us in an OS release.
If, that is, you’re managing your datacenter as if it was your own little… dare I say it, private cloud. In other words, if you think of your datacenter as a wee little cloud, and you manage it like one, then you’ll get the tech you need, because Microsoft has to develop that tech for themselves. If you want to keep managing it the old-fashioned way… well, you’ll get less love.
This whole approach, for me, is the ultimate expression of the Microsoft phrase, “eat the dogfood.” Meaning, use our own products just as our customers would. You just have to make sure you’re eating the same flavor dogfood. Not that MS expects everyone to have their own in-house Azure. No, that’s not the point. The point is that they’re developing for a world where admins do nothing but create units of automation, and business processes (perhaps outside IT) initiate those processes. You’re going to see more and more tools and technologies (um, PowerShell) to facilitate that model of IT operations; you’ll see less and less tech that facilitates the old way (meaning, fewer and less robust GUI tools, I’m guessing).
Desired State Configuration (DSC) is probably an ideal example of this new approach. In the past, when you wanted to configure a few hundred machines to look and behave a certain way, you went clicky-click a few hundred times in a GUI. That’s imperative configuration; you tell each machine what to do. That doesn’t scale to cloud-sized proportions, and so now we’re getting DSC. DSC is declarative configuration, meaning you tell a group of machines what to be. The OS itself figures out how to achieve that state of being. So admins have to shift from thinking “what do I make the machine do” and “how do I tell it what to be.” It’s not unlike Group Policy, actually, which is also declarative, except that DSC will eventually dwarf Group Policy in terms of reach and capability.
Point being, if you’re in the old world of, “I just run through the Wizard and set the machine up,” you’re not aligned with the new world order. Expect fewer wizards, as product teams shift their investment to building things like DSC resources instead. With 12-18 month product cycles, time is in short supply for each new release. One-at-a-time approaches don’t scale to the cloud, so those are likely to get less of that limited amount of time.
Anderson’s post is worth a read. It’s a little high-level - the man is a Corporate VP, after all - but it shows where Microsoft is pointing their collective brain. It uses the word “delight.” It describes in great detail how Microsoft is trying harder to put the customer in the front of every conversation - but, more subtly, it also shows how Microsoft is moving the conversation past “what do customers tell us they want” and more toward “here’s what we see customers needing.” Henry Ford would be proud.

Don Jones
Announcements

It's Safe to Run Update-Help – and you should!

I’m informed that sometime today Microsoft will be posting fixed core cmdlet help files for your downloading pleasure - so it’s safe to run Update-Help again, and you should definitely do so. There are likely a lot of fixes and improvements to the help text, and you won’t be “losing” the parameter value type information from the SYNTAX section.
Maybe schedule an Update-Help for tomorrow morning?
BTW - kudos to the team at Microsoft for getting this issue fixed so quickly. It’s a shame this one snuck past them, but once notified of the problem they really did jump on it. The fact that the problem was (from the public perspective) just with the downloadable help files means it’s an easy fix that doesn’t involve pushing code out through Windows Update (thank goodness).

Don Jones

PowerShell Great Debate: Formatting Constructs

Here’s an easy, low-stakes debate: How do you like to format your scripting constructs? And, more importantly, why do you like your method?
For example, I tend to do this:

`If ($this -eq $that) {

do this

} else {

do this

} `I do so out of long habit with C-like syntax, and because when I’m teaching this helps me keep more information on the screen. However, some folks prefer this:

Don Jones
Announcements

Come to PowerShell Summer School!

Through my company Concentrated Tech, I’ve decided to run a set of three PowerShell Summer School classes (click that link for descriptions). These will be a combo of self-study and weekly online sessions, designed to teach Toolmaking, Practical applications of PowerShell, or how to teach PowerShell in a lunch ’n’ learn style format. Registration is open from now until August 1st, and you’ll also get a discount on some great SAPIEN products to use during class, if you like.
The Toolmaking class will also prepare you for PowerShell VERIFIED EFFECTIVEâ„¢ certification, if you’ve been considering that.
Two of the classes will incorporate group code reviews of student assignments, to help improve your style; the third will include mock delivery sessions to help polish your delivery skills. All will include a private Q&A forum where you can ask questions both of me and of your fellow students while you’re in the self-stufy phase. Classes will meet online, on Wednesdays, for six weeks through August and September.
Planning a vacation in the middle of summer school? It’s fine - we can schedule a make-up online session when you get home. I’m also willing to try and make other accommodations to help make this an effective learning experience for everyone.
All of these classes assume a basic level of PowerShell knowledge, although you’ll get plenty of review material to help you catch up, or dredge up old memories from when you last tried to learn the shell.
Tell a friend, tell a colleague - I don’t do these kinds of offerings all that often; my travel schedule usually precludes it. But a fortuitous schedule has made it possible, so consider taking advantage!

Don Jones
Announcements

Seeking Editor for PowerShell.org TechLetter

The PowerShell.org TechLetter goes out once a month, and we’re looking for an editor to take over the task of building each monthly issue.
You’ll need some basic HTML knowledge, and ideally will have a decent HTML editor. Not FrontPage. You’ll be given articles in both HTML and Word format, and will need to insert those into a master HTML document and (especially in the case of Word), fix the formatting. You’ll have plenty of examples from past issues to work with. Eventually, you’ll also schedule the mid-month mailing.
It all takes a few hours once you have the monthly materials in hand, and you’ll usually have at least a week to do assembly and mailing. You’ll be helping us deliver technical content to a growing audience of more than 3,500 IT professionals and PowerShell enthusiasts!
If you’re interested, contact me. Your pay will be double what I’m currently paid to do this. Which is, sadly, nothing.

Don Jones
Announcements

[UPDATE: It's Safe] CAUTION: Don't Run Update-Help Right Now

UPDATE 2 JULY 2013: Microsoft is informing MVPs that the fix is in, and new help files should be downloadable by (at latest) the morning of 3 July 2013. So get your Update-Help ready to run. More info.
If you haven’t recently run Update-Help… don’t. There’s a problem with the help files that have been produced recently so that instead of:
**-computername **
You’re getting:
-computername
This affects all parameters - no value types will be shown. This has been reported to Microsoft, and they’ve acknowledged receipt of that report and are investigating. Personally, I believe the problem may be related to internal-use-only tools that are used to create the syntax section of the help files, so hopefully it’ll be an easy fix.
The -full and -detail help still shows the correct information, so if you’ve downloaded the borked help files, you’re not totally out of luck.
As far as I can determine, this only currently affects core PowerShell cmdlets, not add-in modules from product teams like Exchange, etc. I believe that’s because the core cmdlets were just updated and re-published, something the PowerShell team tends to do a bit more frequently than some of the other product groups.
I’ll keep you posted as I learn anything new.

Don Jones

PowerShell Great Debate: To Accelerate, or Not?

At his Birds of a feather session at TechEd 2013, Glenn Sizemore and I briefly debated something that I’d like to make the topic of today’s Great Debate. It has to do with how you create new, custom objects. For example, one approach - which I used to favor, but now think is too long-form:

$obj = New-Object -Type PSObject $obj | Add-Member NoteProperty Foo $bar $obj | Add-Member NoteProperty This $that We saw some variants in The Scripting Games, including this one:

Don Jones
PowerShell for Admins

Pipeline or Script? That is the Question

When I teach PowerShell classes, I often start by assuring students that, with the shell, you can _accomplish a great deal without ever writing a script. _And it’s true - you can. Unlike predecessor technologies like VBScript, PowerShell lets you pack a lot of goodness into a one-liner - or even into several lines run manually in the console.
What I never say is _you can accomplish  anything without ever writing a script. _That isn’t true. I see folks struggle all the time to squeeze something into a one-liner pipeline, when life would be so much easier if they switched a script-style, procedural approach.
So what’s the tipping point?
Actually, it’s really easy to spot. You should be writing a script if:

Don Jones

PowerShell Great Debate: Capturing Errors

Hot on the heels of our last Great Debate, let’s take the discussion to the next logical step and talk about how you like to capture errors when they occur.
The first technique is to use -ErrorVariable:

`Try { Get-WmiObject Win32_BIOS -comp nothing -ea stop -ev mine } Catch {

use $mine for error

} `Another is to use the $Error collection:

`Try { Get-WmiObject Win32_BIOS -comp badname -ea stop } Catch {