Save 10%Pay yearly on any plan. 6% half-yearly, 3% quarterly. Help centreWhatsAppTelegram TeamsOpen a ticket

PowerShell 2.0 vs 3.0: What's the Difference?

What PowerShell 3.0 added over 2.0: simpler syntax, automatic module loading, CIM cmdlets, scheduled jobs, web cmdlets and workflows. And why it still matters today.

3 min readBy Shailabh

Reviewed by the AmazingRDP technical team

PowerShell 2.0 compared with PowerShell 3.0

Need a Windows server to run and test scripts on? A Windows VPS gives you full admin access. See Windows VPS from $8.99

PowerShell 2.0 shipped with Windows 7 and Windows Server 2008 R2 in 2009. Version 3.0 followed with Windows 8 and Windows Server 2012 in 2012. Both are history now, and the question still comes up for one reason: old scripts. A script written for 2.0 runs on newer versions almost unchanged, and a script that uses 3.0 features fails on 2.0. Knowing the line between them tells you which you have.

Which version am I running?

$PSVersionTable.PSVersion

Every supported Windows today includes Windows PowerShell 5.1. PowerShell 7 is a separate, newer program (pwsh) that installs alongside it.

The differences at a glance

AreaPowerShell 2.0PowerShell 3.0
Runs on.NET Framework 2.0 / 3.5.NET Framework 4
ModulesLoaded by hand with Import-ModuleLoaded automatically on first use
Filtering syntaxScript block requiredShort form allowed
Hardware and system queriesWMI cmdletsCIM cmdlets added
Web requestsThrough .NET classesInvoke-WebRequest, Invoke-RestMethod
Scheduled tasksOutside PowerShellScheduled jobs
HelpFixed, shipped with WindowsUpdatable with Update-Help
Remote sessionsLost when the connection dropsCan be disconnected and resumed
Editor (ISE)BasicIntelliSense, snippets, command pane
Long-running processesBackground jobsWorkflows added

Simpler syntax

The same filter in both versions:

Get-Service | Where-Object { $_.Status -eq 'Running' }
Get-Service | Where-Object Status -eq 'Running'

The first line works everywhere. The second is the short form from 3.0; on 2.0 it is an error. The same applies to ForEach-Object with a property name. This short form is the most common reason a newer script fails on an old system.

Objects made easily

[pscustomobject]@{ Name = 'web01'; Port = 443 }
[ordered]@{ First = 1; Second = 2 }

Both arrived in 3.0. On 2.0 the equivalent was New-Object PSObject -Property, which did not keep the order of the properties.

Modules that load themselves

In 2.0 a command from a module did not exist until you ran Import-Module. From 3.0, typing the command is enough: PowerShell finds the module and loads it. Scripts written on 3.0 or later therefore often lack the import lines that 2.0 needs.

CIM in place of WMI

Get-WmiObject Win32_OperatingSystem
Get-CimInstance Win32_OperatingSystem

The CIM cmdlets from 3.0 use the standard WS-Management protocol for remote machines, which passes firewalls more easily than the older method, and return dates in a readable form. The WMI cmdlets no longer exist in PowerShell 7, so new scripts should use CIM.

Web cmdlets

Invoke-RestMethod https://api.github.com/zen
Invoke-WebRequest https://example.com/file.zip -OutFile file.zip

Before 3.0, a download or an API call meant writing .NET code by hand.

Scheduled jobs and resumable sessions

3.0 let PowerShell register its own scheduled jobs (Register-ScheduledJob) and keep their results for later. Remote sessions gained Disconnect-PSSession and Connect-PSSession: start something on a server, disconnect, and pick the session up again from another PC.

Workflows

Workflows were 3.0's answer to long, interruptible, parallel tasks. They never caught on, are not part of PowerShell 7, and are not something to build on today. For parallel work, current PowerShell has ForEach-Object -Parallel.

Why 2.0 matters today: it is going away

The 2.0 engine stayed inside Windows for many years as an optional feature, for old scripts and programs. Microsoft declared it deprecated in 2017, because it lacks the security features of later versions, and has removed it from current releases of Windows 11 and Windows Server. What to do:

  • Search your scripts and scheduled tasks for -Version 2 and remove it. Nearly all 2.0 scripts run unchanged on 5.1.
  • Check old installers and management tools that may call the 2.0 engine, and update them.
  • State what a script needs in its first line, so that it fails clearly on an older system:
#Requires -Version 5.1

What to write for today

Target Windows PowerShell 5.1 if a script must run on any Windows without installing anything, and PowerShell 7 for new work, cross-platform scripts and speed. Everything described here as "new in 3.0" works in both.

For a Windows machine to test scripts on, see our Windows VPS plans. Related: make .ps1 files open with PowerShell, set the time zone with PowerShell and enable a port through PowerShell.

Questions

What is the main difference between PowerShell 2.0 and 3.0?

Version 3.0 added simpler syntax, automatic module loading, CIM cmdlets, web cmdlets, scheduled jobs and resumable remote sessions.

How do I check my PowerShell version?

Run $PSVersionTable.PSVersion.

Is PowerShell 2.0 still supported?

No. Microsoft deprecated it in 2017 and has removed it from current Windows releases.

Will my PowerShell 2.0 script run on newer versions?

Almost always, yes. Scripts written for 2.0 run on Windows PowerShell 5.1 with few or no changes.