What’s New In Version PowerShell 2.0

Windows PowerShell 2.0 CmdletsWindows PowerShell Tutorial

PowerShell 1.0 has about 125 cmdlets, whereas v 2.0 has a minimum of 230.  The precise number depends on whether you are running Windows 8, 7, or XP.

 ♣

PowerShell Transactions

On Vista and later on operating systems PowerShell supports database style ‘ACID’ transactions, whereby you can commit or roll-back a sequence of operations.

PowerShell Modules

Import-Module loads a bunch of dll and scripts, it replaces the Add-PSSnapin.   See more about the PowerShell modules directory.

#REQUIRES -Version 2.0

This is not merely a remark, but an instruction to PowerShell v 1.0 that it cannot run the code which follows.

# PowerShell 2.0 Requires Example
# Requires -Version 2.0
Enter-PSSession IpAddress or FQDM

Research Techniques for Finding New PowerShell 2.0 Cmdlets

One way of checking for new PowerShell 2.0 cmdlets is to use Get-Command with the -Noun or -verb parameter.  For example, I heard a rumour there was a new cmdlet to measure.

Research Measure-Object

# Research measure cmdlets
Clear-Host
Get-Command -verb measure

CommandType   Name
———–  —-
Cmdlet    Measure-Command
Cmdlet    Measure-Object

Research New Event cmdlets

# Research new event Windows PowerShell 2.0 cmdlets
Clear-Host
Get-Command -commandType cmdlet *Event*

Note 1: Get-WinEvent looks interesting.

List All Cmdlets

# Research new Windows PowerShell 2.0 cmdlets
Clear-Host
Get-Command -CommandType Cmdlet

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

General Advice For PowerShell 2.0 and 1.0.

Four Reasons to Learn Windows PowerShell

  1. Think of learning PowerShell as a more convenient method of configuring the server than using the corresponding GUI.  I can foresee running PowerShell scripts that will diagnose server problems.  With PowerShell you can run queries that are not possible from the GUI.  On a good day such a script would even cure the problem – magic! 

    To come back down to earth, let us start with a trivial example to illustrate the capability of PowerShell.  As you may know, the Task Manager will display all the processes, yet with PowerShell you can not only list all processes, but also group them by company (Microsoft, HP and Roxio).  All you need is this one-liner:
    Get-Process | group-Object company

  2. PowerShell will achieve the same results as VBScript, but with fewer commands.  For instance, PowerShell makes scripting WMI much easier, for example, try: Get-WmiObject win32_BIOS.  More good news, you can even use PowerShell to replace VBScript for Active Directory scripts.
  3. I have a sense that there is a changing of the guard; out with old CMD commands, and in with new PowerShell language.  More importantly, the new PowerShell language will give you command line control of the Windows operating system; this is similar to the power that Bash commands exert over the UNIX operating system. 

    In a nutshell: PowerShell really is the way of the future.

  4. The main reason for learning PowerShell is so that you can administer Exchange Server 2007, and also the Longhorn server that will succeed Windows Server 2003.  Microsoft’s thinking is that the point has arrived where complex products like Exchange and Longhorn have so many menus and sub-menus to configure via a GUI, that we need an alternative.  Hence the easy-to-use scripting language called PowerShell.

Note: Existing Windows executables, such as Ipconfig and ping, perform in the PS Shell just as they do in the old CMD ‘DOS box’.

SolarWinds Firewall Browser Solarwinds Free Firewall Browser

Here is an utility where you can review firewall settings such as access control lists (ACL), or troubleshoot problems with network address translation (NAT).

Other reasons to download this SolarWinds Firewall Browser include managing requests to change your firewall settings, testing firewall rules before you go live, and querying settings with the browser’s powerful search options.

Guy recommends that you download a copy of the SolarWinds free Firewall Browser.

Simple PowerShell Examples

Preamble, Start, Run PowerShell. 
At the command line type (In that dark blue shell):

Get-Service

Here is another example, type:
Get-WmiObject win32_computersystem

I first realised the ability of PowerShell when I saw three lines of PowerShell replace about twenty lines of VBScript.  The task is to interrogate Win32_classes, we can either use the traditional VBScript and WMI, or the new PowerShell with its Verb-Noun commands.

VBScript

 Windows PowerShell

‘ Memory.vbs
‘ VBScript to discover how much RAM in computer
‘ Author Guy https://computerperformance.co.uk/
‘ Version 1.3 – August 2005
‘ ——————————————————-‘
Option Explicit
Dim objWMIService, objComputer, colComputer
Dim strLogonUser, strComputer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
Wscript.Echo "System Name: " & objComputer.Name _
& vbCr & "Total RAM " & objComputer.TotalPhysicalMemory
Next

WScript.Quit

‘ End of Sample Memory WMI / VBScript

# Windows PowerShell script
# Displays ComputerName and memory
$CompSys = Get-WmiObject win32_computersystem

"System Name = " + $CompSys.name
"Memory = " + $CompSys.TotalPhysicalMemory

 

See PowerShell 3.0 »

Summary of What’s New In Windows PowerShell v 2.0

Remoting is the big new feature of PowerShell v 2.0 followed closely by the ISE which makes writing scripts so much easier.  Other than that, there lots of neat extra cmdlets.

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

 


See more Windows PowerShell sections

PowerShell Home   • Introduction  • Dreams   • 3 Key Commands   • Free Permissions Analyzer

PowerShell Real-life Examples   • PowerShell Techniques   • PowerShell Syntax   • Contact

PowerShell ISE  • PowerShell 2.0   • PowerShell v 3.0   • PowerShell v 4.0   • PowerShell v 4.0

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.