For me, the best part of the recent Windows 8.1 and Windows Server 2012 R2 previews was the introduction to PowerShell 4.0. There are a number of welcome changes to v4 but fortunately for you, assuming you are already running v3, there jump isn’t as dramatic as I feel it was going from 2.0 to 3.0.

Jeffery Hicks

Jeffery Hicks is a multi-year Microsoft MVP in Windows PowerShell, Microsoft Certified Professional and an IT veteran with 25 years of experience specializing in automation. He works today as an author, trainer and consultant.

And I pray at in 2013 nobody is still running PowerShell 1.0. In this article I want to give you a peek at some of the new features in PowerShell 4.0. These are items that I think are useful and is by no means an exhaustive look. As with any preview, things might (and usually do) change with the final shipping product.

One of the obvious changes you’ll notice is the data in $PVersionTable.



General improvements ^

There are a few general improvements to the shell that I think you’ll like. First off, a big change to Save-Help. In PowerShell 3.0 we can download and save help content to a local server. We can then point our clients to the local share instead of everyone downloading from Microsoft.

The problem is that Save-Help only works for modules installed on the computer running the cmdlet. This means if your server has modules that you don’t have you still have to update help from that server. One work around, at least for all of the common modules in Windows Server 2012 is to install Remote Server Administration (RSAT) on a Windows 8 client. But now the HelpInfo URI is preserved during remoting so you can run a command sequence like I did in the screenshot below.

HelpInfo URI

HelpInfo URI

I also like that modules that don’t support Update-Help are now skipped without any error messages.

Another handy enhancement is to include process owner information with Get-Process:

get- process  -includeusername

get- process  -includeusername

However, you can’t combine it with –Computername. You’ll need to use remoting as I did below.

Include process owner with computer name in Get-Process

Include process owner with computer name in Get-Process

Next, one of my favorite bug fixes involving Import-CSV. This is a fantastic cmdlet for turning any CSV source into objects. Unfortunately, if your CSV file has any blank lines, you’ll get empty objects which isn’t very helpful. But now in PowerShell 4.0 blank lines are ignored and Import-CSV works the way you expect.

Scheduled job enhancements ^

I loved the new scheduled job feature in PowerShell 3.0. In PowerShell 4.0 it gets even better thanks to a few enhancements. First, you no longer need to load the PSScheduledJob module in order to get the new job types. This also applies to workflow jobs. Now, when you run Get-Job you’ll see all jobs.

I also like that I can now run a scheduled job immediately. Often, I’ll set up a scheduled job but I also want to run it right now. In PowerShell 3.0 this was a multiple step process. But 4.0 offers me a –RunNow parameter as you can see in the next screenshot.

RunNow parameter

RunNow parameter

Desired State Configuration ^

Finally, the biggest change, and the one garnering all the attention is Desired State Configuration (DSC). Just as workflow was a compelling feature in 3.0, DSC is just as exciting for 4.0. Obviously I’m not going to cover this feature in depth here. But I want to give you a taste.

Like PowerShell workflows, DSC is more than just another way to script. This is a new management paradigm that leverages PowerShell. The premise is that using PowerShell you can define what software should be installed and configured for a given server instance as well as configuration settings such as files, folders, registry keys and more.

You start with a PowerShell script that defines the desired configuration for a managed node.

Next, you turn this script into a MOF file by executing the script and specifying an output path.

You will end up with a MOF file which can then be “applied”.

This command will find all MOF files in the path and apply them to the designated nodes. By default, the configuration will be kicked off as a background job or you can do as I did and use –Wait parameter. You can see the result below.

Desired State Configuration

Desired State Configuration

Think you’re servers may have drifted out of your desired configuration? You can re-run the command and only you’ll only get the changes necessary to bring the system back into compliance. You’ll be hearing much more about this feature in the weeks ahead.

Summary ^

To the best of my knowledge PowerShell 4.0 will ship with Windows 8.1 and Windows Server 2012 R2. I am assuming it will be eventually available for any platform that can currently run PowerShell 3.0. I realize many of you are just now getting to PowerShell 3.0, but don’t feel you now need to jump to 4.0. Many of the changes in 4.0, such as DSC, are intended for managing servers running Windows Server 2012 and later and based on my conversation with many people, those types of upgrades aren’t a prevalent yet.

If you have access to a system running PowerShell 4.0, be sure to read About_Windows_PowerShell_4.0 as well as the help topics for the Desired State Configuration cmdlets.

Join the 4sysops PowerShell group!

Your question was not answered? Ask in the forum!

1 Comment
  1. Author
    Jeff Hicks 6 years ago

    I need to clarify a point. DSC is supported on Windows Server 2008 R2 or later according to MVP Steve Murawski. So PowerShell v4 may be more compelling than I originally thought.


Leave a reply

Your email address will not be published. Required fields are marked *


© 4sysops 2006 - 2019


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account