What's New in PowerShell 3.0

New Features in Windows PowerShell 3.0What's New in PowerShell 3.0

The advent of Windows 8 (client) and Windows Server 8 see the introduction of a new version of PowerShell.  My aim on this page is to get you started, and to explain these new features.

 ♦

Download PowerShell v3.0 CTP

As an alternative to installing Windows 8, if you have Windows 7 with SP1, or Windows Server 2008 R2 SP1, then you can download the Community Technology Preview version, see here for PowerShell 3.0 CTP.

Launching PowerShell v 3.0PowerShell 3.0

This is how to get started from the Metro user interface in Windows 8.

  • From anywhere in the Metro UI, press the 'p' key.  You should see a list of the programs and Apps beginning with the letter 'p'.
  • At this point you could 'Pin' the 'Windows PowerShell ISE'.  Simply right-click the icon and selecting 'Pin' at the bottom right of the screen.
  • Incidentally, I prefer the GUI (ISE) version to the plain command line Windows PowerShell.
  • I like to drag the PowerShell ISE tile to the left of my screen because it's one of the most important Windows 8 Tiles that use.
  • To download Windows 8 with PowerShell 3.0 see here.

Check PowerShell's Version

# PowerShell Version
$PSVersionTable

Once your PowerShell ISE arrives it's worth double-checking its version: type: $PSVersionTable

Result
Name        Value
-------       -------
PSVersion  3.0  [Assuming you have Windows 8]

Note 1: Alteratively you could try: $Host, or even Get-Host.

Check PowerShell version with $PSVersionTable.

What's New In PowerShell v 3.0?Microsoft Windows 8 PowerShell

The Auto-complete feature saves typing time, and reduces my typos.  As you begin to type a cmdlet so you see a pick-List of likely nouns to append to your verb.

See screenshot to the right, once you have typed the verb (Get) and the first letter of the noun (-P) then the list of available cmdlet appears.  In this example if you pressed 'Enter' then PowerShell would complete the typing (Get-Partition).  To be precise, the list usually appears once you have typed the verb and the hyphen.

Microsoft also provide a nifty way to group the cmdlets by module, see under 'Commands' in the screenshot below taken from the PowerShell 3.0 ISE:

Windows PowerShell v3

Guy Recommends: Free WMI Monitor for PowerShellSolarwinds Free WMI Monitor for PowerShell

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft's operating systems.  Fortunately, SolarWinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your PowerShell scripts.

Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory, or Exchange Server. Give this WMI monitor a try - it's free.

Download your free copy of WMI Monitor

See Dozens of New PowerShell 3.0 CmdletsMicrosoft Windows 8 PowerShell

Whereas PowerShell v 2.0 brought remoting, PowerShell v 3.0 brings hundreds of new cmdlets.

# PowerShell 3.0 Cmdlet count
$Pv3 = Get-Command *
$Pv3.count

You could shorten to: (Get-Command *).count

List Just Cmdlets and Functions

You could modify the script to avoid the duplication of cmdlets' aliases.

Observe how this script sorts the 'CommandType' in descending order, and the 'Name' in ascending order.

Clear-Host
$Pv3 = Get-Command | `
Where-Object {$_.CommandType -eq 'Function' -or $_.CommandType -eq 'Cmdlet'}
$Pv3 | Sort-Object -property `
@{Expression="CommandType";Descending=$true}, `
@{Expression="Name";Descending=$false} | FT Name, CommandType -auto
$Pv3.count

Note 2: The biggest expansion area in PowerShell 3.0's is of functions.  I draw your attention to this because many of these 'Functions' look for all the world like cmdlets.  In particularly, I am thinking of the 'Net' family with nouns such as: NetIPAddress, NetIPAdapter and NetIPInterface.

To see what I mean try this:

Clear-Host
$Pv3f = Get-Command | `
Where-object {$_.CommandType -eq 'Function'}
$Pv3f | Sort-Object -property `
@{Expression="CommandType";Descending=$true}, `
@{Expression="Name";Descending=$false} | FT CommandType, Name -auto
$Pv3f.count

Note 3: I got 513 functions in PowerShell 3.0, but only 38 in PowerShell 2.0.

Show-Command

There is another useful new cmdlet called Show-Command; the idea is for beginners to research more about the syntax of a cmdlet, I have chosen Get-Eventlog, but you could experiment with any PowerShell Verb-Noun pair.

# PowerShell 3.0 Favourite New Command
Show-Command Get-Eventlog

PowerShell Show-Command Get-Event

Note 4: See more about Show-Command.

Engineer's Toolset v10Guy Recommends: SolarWinds Engineer's Toolset v10

This Engineer's Toolset v10 provides a comprehensive console of 50 utilities for troubleshooting computer problems.  Guy says it helps me monitor what's occurring on the network, and each tool teaches me more about how the underlying system operates.

There are so many good gadgets; it's like having free rein of a sweetshop.  Thankfully the utilities are displayed logically: monitoring, network discovery, diagnostic, and Cisco tools.  Try the SolarWinds Engineer's Toolset now!

Download your fully functional trial copy of the Engineer's Toolset v10

PowerShell 3.0 Intellisense

When you make mistakes, PowerShell 3.0 underlines the error in red, furthermore, if you hover on the wavy line Intellisense supplies suggestions to correct the error.  For example:

# PowerShell 3.0 Intellisense
Get-Service | Where {$_.status -eq running }

Problem:  running should be encased in single speech marks.  It should be:
Get-Service | Where {$_.status -eq 'running' }

Solution: Click on the red line and PowerShell suggests a solution.

PowerShell Show-Command Get-Event

The 'Where' Statement is Simplified in PowerShell 3.0

The best way to see what's changed with WHERE is through two examples:

# PowerShell 2.0 Where {}
Get-Service | Where {$_.status -eq 'running' }

Note 5: The above example works in version PowerShell 2.0 and 3.0
Note 6: Below is a simplification, but it works only in PowerShell v 3.0

# PowerShell 3.0 Plain Where
Get-Service | Where status -eq 'running'

Note 7: Observe how the {curly brackets}, the placeholder ($_.) and the 'speech marks' have been stripped out, making this Where-Object command much easier for everyone to read, and for newbies to type.  Incidentally, some old-hands cannot believe this simplified syntax really will work!  But it does!!  See more on PowerShell 3.0 Where statement.

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds' Network Performance Monitor will help you discover what's happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of Solarwinds' Network Performance Monitor

More New Features in PowerShell 3.0PowerShell 3.0 Passthru

Out-GridView now has the -passthru parameter.  The benefit occurs if you select rows with the mouse and then refresh the command, the output reflects just that data, in effect selecting enables filtering.  See screenshot to the right where I have selected just 5 rows, if we clicked on the 'OK' button -passthru would filter just: dlhost, LogonUI etc...

See more on -PassThru in PowerShell 3.0

Update-Help  Anyone who writes articles knows there are inevitably mistakes, and help files are no exception, what's new in version 3.0 is an Update-Help cmdlet.  This cures those small errors, or annoying typos, in the built-in documentation.  Naturally, for this to be effective someone at Microsoft must update the master help file on the internet!

Change The Default Parameters  It's possible to adjust the default value for a cmdlet's parameter.  For example, suppose you wanted Out-File to write in ASCII, then try this:
$PSDefaultParameterValues.('Out-File:encoding = ascii')

Where Encoding is the parameter (stripped of its hyphen), and ascii is your preferred format.  Pay close attention to the syntax including the parenthesis style brackets.  Note also the use of the = sign here, and not PowerShell's usual -eq.  See more on changing PowerShell's default parameters.

Ordered Hash Tables in PowerShell 3.0

#Hash Table Problem
$GuyHash = @{Wales=1; England=2; Scotland=3; Ireland =4}
$GuyHash

Problem: Sequence 3,1,4,2

Name Value
--------  ----
Scotland  3
Wales      1
Ireland    4
England   2

Solution: Precede the hash table with [Ordered]

#Ordered Hash Table Solution
$GuyHash = [Ordered]@{Wales=1; England=2; Scotland=3; Ireland =4}
$GuyHash

Name Value
--------  ----
Wales      1
England   2
Scotland  3
Ireland    4

See more on PowerShell hash tables.

SolarWinds Response Time Viewer for WiresharkGuy Recommends: Response Time Viewer for Wireshark

Here is a free tool to troubleshoot network connection and latency problems.  Key concept: this is a free tool from SolarWinds that analyzes network packets captured by Wireshark (also a free tool).

When you inspect the data in the Response Time Dashboard, if you hover over an application such as Teredo or TCP, then you get an orange box showing a breakdown of network and application response times, note the 'Peak value' in addition to the 'Average'.

Download your free trial of SolarWinds Response Time Viewer for Wireshark

New PowerShell 3.0 Features For Server Administrators

Microsoft realize Administrators need more features to help manage Windows Server Core.  In particular Administrators need easy ways to automate tasks which will fan out over dozens of virtual servers.  The problem has been that while Windows 8 Server core is more secure, it's harder to administer.  The solution is PowerShell.  But PowerShell 2.0 could do better, as could Windows Server 2008.  So the new dream team will be Windows Server 8 with PowerShell 3.0.

"A small problem times a large frequency, like you get with virtualization, in turn can just drive you crazy. So you've got to have great manageability."   Jeffrey Snover

To achieve these goals PowerShell 3.0 has enhanced workflow capabilities, for instance you can use events to trigger Scheduled jobs.  Furthermore complex PowerShell 3.0 scripts are more likely to complete thanks to more robust WinRM sessions, which proceed or resume in the face of network interruptions. See more on PowerShell 3.0 workflow

New PowerShell 3.0 Features For Developers

Developers can extend their scope by writing cmdlets in .NET, Windows Workflow, there is also a whole set of CIM cmdlets.  For those with the knowledge, there is also the ability to configure REST APIs using PowerShell and OData. 

By using schemas based on MOF (Managed Object Format) developers will find it simpler to write WMI providers.  While PowerShell has always been great at extensibility, these easier working practices arise because WMI is no longer dependent on COM (Component Object Model).

New Feature: PowerShell 3.0 Redirection

PowerShell 3.0 offers the ability to redirect output to text files.  This is particularly useful where an experimental script produces warning messages or needs debugging.

Pipeline   1> 
Error       2>  (Same as PowerShell 2.0)
Warning  3>
Debug     4>

See more of PowerShell 3.0 Redirection.

Earlier Improvements in PowerShell v1.0 --> 2.0

The biggest improvement brought by version 2.0 was remote management.  Being able to run PowerShell commands not only on the local machine, but on networked computers was welcome advance.

While PowerShell is a command-line language, the ISE GUI makes it easier to edit then replay scripts,  I also particularly like the ability to store variations of my scripts on different tabs.

Each new version of PowerShell comes with new built-in cmdlets, for example Send-Mail in Exchange and also numerous new Active directory Verb-Noun pairing.

Background jobs saves waiting.  You can even run background jobs on a remote computer and store the results locally.

See more real-life tasks for PowerShell »

Summary of What's New In PowerShell 3.0

This page is just to get you started with Windows PowerShell 3.0.  The easiest way to be begin is to download the Windows 8 Customer Preview.  Once installed, 'Pin' the ISE version to the Metro UI; just type 'p' and select Windows PowerShell ISE and away you go!

If you like this page then please share it with your friends

 


See more Microsoft PowerShell v 3.0

PowerShell Tutorials  • What's New in PowerShell 3.0  • PowerShell 3.0 Foreach-Object

PowerShell Show-Command  • Out-GridView -PassThru  • PowerShell Ordered Hash Tables

PowerShell Version 3.0  • PowerShell 3.0 Get-ChildItem  • PowerShell 3.0 Update-Help

 *


Custom Search

Site Home

Guy Recommends: SolarWinds' NPM - Review of Orion NPM
Network Performance Monitor

SolarWinds' performance monitor is designed for detecting network outages, making it easy to see what's working, and what needs your attention.

This utility guides you through creating network maps; it also helps identifying whether the root cause is faulty equipment, or resource overload. Give NPM a try.

Download a free trial of Network Performance Monitor

Article by: Guy Thomas Copyright © 1999-2017 Computer Performance LTD All rights reserved.

Please report any broken link, or an error to: