Prof. Powershell

PowerShell vNext is vBest

Three good reasons to like the next version of PowerShell.

Unless you've been hiding in a bunker recently, I'm sure you've heard about Windows 8 and the release of a CTP for PowerShell 3.0. If you've been trying to avoid PowerShell I think you'll find that hard to do once PowerShell 3.0 and Windows 8 ships. Even if you don't intend on migrating to Windows 8, you will want to deploy the PowerShell v3 bits.

PowerShell is now bundled as part of the Management Framework, which also includes WinRM for secure remote management and an updated version of WMI. PowerShell v3 may finally be the version that gets admins off the sideline and into the game. Here are my top three reasons why:


Simplified Language
In PowerShell v2 we wrote expressions like this:

PS C:\> Get-service | where {$_.status -eq "running"}

This will continue to work in v3, but now you can use a much simpler language and one that doesn't rely on the cryptic $_.

PS C:\> Get-Service | where status -eq "running"

Here's another example, and yes I know this isn't the way you would really accomplish this task, but it illustrates the point:

PS C:\> ps | where name -eq notepad | foreach kill

Or you can use the new $PSItem automatic variable.

PS C:\> "foo","bar" | foreach {$PSItem.ToUpper()}
FOO
BAR
PS C:\> Dir $env:temp -file | where length -gt 1mb | select Fullpath,@{Name="Size";Expression={$PSItem.length}}

A number of cmdlets have also been improved, like Get-Childitem which now can easily display files by attribute such as system and hidden.

Robust Remote Sessions
In PowerShell v2 when you established a remote session it was subject to the whims of your network. If the connection dropped you essentially had to start all over.

In v3 we now have very robust sessions. In fact, you can start a session, kick off some commands and return to your prompt. When you start a new PowerShell session, even on a different computer, you can connect again to the same sessions.

Jobs and Tasks
PowerShell takes background jobs and tasks to a whole new level. We still have background jobs, but now you can pause and resume jobs. PowerShell v3 also can interact directly with the Task Scheduler so that you can create PowerShell based tasks:

$trigger=New-JobTrigger -At 06:00 -DaysOfWeek Friday -weekly
Register-ScheduledJob -name "FridayJob" -ScriptBlock {dir $env:temp -rec | out-file c:\temp.txt} -Trigger $trigger

This job is persistent because it is registered with the task scheduler and not just PowerShell.

Frankly, there are many, many exciting features and we'll be exploring more of them in 2012, especially as the final release date nears

So what should you do now? First, don't put off learning PowerShell. The more you can learn now, the easier it will be to pick up the new features when v3 finally ships. At the same time, setup the v3 CTP bits in a test environment so you can start getting a feel for them. Remember, we're only at a CTP so things can and will change.

You can download the Management Framework 3.0 CTP 1 here.


About the Author

Jeffery Hicks is a Microsoft MVP and an IT veteran with almost 20 years of experience, much of it spent as an IT consultant specializing in Windows server technologies. He works today as an independent author, trainer and consultant. His latest book is Managing Active Directory with Windows PowerShell 2.0: TFM (SAPIEN Press 2011). Follow Jeff on Twitter and on his blog.

Reader Comments:

Thu, Oct 6, 2011 Jeff Hicks

You can temporarily set the compatibility level of the shell to version 2.0. As for Vista support, you can still do a lot of remote management via WMI but I think MS expects admins to be running the most current OS.

Wed, Oct 5, 2011 dpc Ohio

Was overheard that v3 could exist with v2. Any truth to that rumor? More importantly, any successful road map on how-to? Thanks JH !

Wed, Oct 5, 2011 Anonymous

Does not even run on Windows Vista. No XP support is understandable but Vista? Looks like the new Microsoft is just like Apple. Always pushing only the latest.

Tue, Oct 4, 2011 jv NY-Metro

Very good. P3 will be the ultimate tool Anything that save typring is the best. Goo article too.

Add Your Comment Now:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above