Screenshot of a PowerShell 7 session in Windows Terminal | |
| Paradigm | Imperative, pipeline, object-oriented, functional and reflective |
|---|---|
| Designed by | Jeffrey Snover, Bruce Payette, James Truher (et al.) |
| Developer | Microsoft |
| First appeared | November 14, 2006; 17 years ago |
| Stable release | |
| Typing discipline | Strong, safe, implicit and dynamic |
| Implementation language | C# |
| Platform | PowerShell: .NET Windows PowerShell: .NET Framework |
| OS | |
| License | MIT License[2] (but the Windows component remains proprietary) |
| Filename extensions |
|
| Website | |
| Influenced by | |
| Python, Ksh, Perl, C#, CL, DCL, SQL, Tcl, Tk,[3] Chef, Puppet | |
PowerShell includes its own extensive, console-based help (similar to man pages in Unix shells) accessible via the Get-Help cmdlet. Updated local help contents can be retrieved from the Internet via the Update-Help cmdlet. Alternatively, help from the web can be acquired on a case-by-case basis via the -online switch to Get-Help.


- cmdlets (.NET Framework programs designed to interact with PowerShell)
- PowerShell scripts (files suffixed by
.ps1) - PowerShell functions
- Standalone executable programs
Extended Type System
The number of cmdlets included in the base PowerShell install has generally increased with each version:
| Version | Cmdlets | Ref |
|---|---|---|
| Windows PowerShell 1.0 | [38] | |
| Windows PowerShell 2.0 | [39] | |
| Windows PowerShell 3.0 | [40] | |
| Windows PowerShell 4.0 | ? | |
| Windows PowerShell 5.0 | [41] | |
| Windows PowerShell 5.1 | [] | |
| PowerShell Core 6.0 | ? | |
| PowerShell Core 6.1 | ? | |
| PowerShell Core 6.2 | ? | |
| PowerShell 7.0 | [] | |
| PowerShell 7.1 | ? | |
| PowerShell 7.2 | ? | |
| PowerShell 7.4 |
# Definition of static parameters # Definition of dynamic parameters # Set of instruction to run at the start of the pipeline # Main instruction sets, ran for each item in the pipeline # Set of instruction to run at the end of the pipeline
Desired State Configuration
Upon running a configuration, DSC will ensure that the system gets the state described in the configuration. DSC configurations are idempotent. The Local Configuration Manager (LCM) periodically polls the system using the control flow described by resources (imperative pieces of DSC) to make sure that the state of a configuration is maintained.
Initially using the code name “Monad”, PowerShell was first shown publicly at the Professional Developers Conference in October 2003 in Los Angeles. All major releases are still supported, and each major release has featured backwards compatibility with preceding versions.
Windows PowerShell 1.0

Windows PowerShell 2.0

Windows PowerShell 3.0
- Scheduled jobs: Jobs can be scheduled to run on a preset time and date using the Windows Task Scheduler infrastructure.
- Session connectivity: Sessions can be disconnected and reconnected. Remote sessions have become more tolerant of temporary network failures.
- Improved code writing: Code completion (IntelliSense) and snippets are added. PowerShell ISE allows users to use dialog boxes to fill in parameters for PowerShell cmdlets.
- Delegation support: Administrative tasks can be delegated to users who do not have permissions for that type of task, without granting them perpetual additional permissions.
- Help update: Help documentations can be updated via Update-Help command.
- Automatic module detection: Modules are loaded implicitly whenever a command from that module is invoked. Code completion works for unloaded modules as well.
- New commands: Dozens of new modules were added, including functionality to manage disks
get-WmiObject win32_logicaldisk, volumes, firewalls, network connections, and printers, which had previously been performed via WMI.[further explanation needed]
Windows PowerShell 4.0
New features in PowerShell 4.0 include:
- Desired State Configuration:[83][84][85] Declarative language extensions and tools that enable the deployment and management of configuration data for systems using the DMTF management standards and WS-Management Protocol
- New default execution policy: On Windows Servers, the default execution policy is now
RemoteSigned. - Save-Help: Help can now be saved for modules that are installed on remote computers.
- Enhanced debugging: The debugger now supports debugging workflows, remote script execution and preserving debugging sessions across PowerShell session reconnections.
- -PipelineVariable switch: A new ubiquitous parameter to expose the current pipeline object as a variable for programming purposes
- Network diagnostics to manage physical and Hyper-V‘s virtualized network switches
- Where and ForEach method syntax provides an alternate method of filtering and iterating over objects.
Windows PowerShell 5.0

Key features included:
- The new
classkeyword that creates classes for object-oriented programming - The new
enumkeyword that creates enums OneGetcmdlets to support the Chocolatey package manager[87]- Extending support for switch management to layer 2 network switches.[88]
- Debugging for PowerShell background jobs and instances of PowerShell hosted in other processes (each of which is called a “runspace”)
- Desired State Configuration (DSC) Local Configuration Manager (LCM) version 2.0
- DSC partial configurations
- DSC Local Configuration Manager meta-configurations
- Authoring of DSC resources using PowerShell classes
Windows PowerShell 5.1
PowerShell Core 6
- The
-Parallelswitch for theForEach-Objectcmdlet to help handle parallel processing - Near parity with Windows PowerShell in terms of compatibility with built-in Windows modules
- A new error view
- The
Get-Errorcmdlet - Pipeline chaining operators (
&&and||) that allow conditional execution of the next cmdlet in the pipeline - The ?: operator for ternary operation
- The
??operator for null coalescing - The
??=operator for null coalescing assignment - Cross-platform
Invoke-DscResource(experimental) - Return of the
Out-GridViewcmdlet - Return of the
-ShowWindowswitch for theGet-Help
Comparison of cmdlets with similar commands
-
lsandmanaliases are absent in the Linux version of PowerShell Core. - Clear-Host is implemented as a predefined PowerShell function.
- Available in Windows NT 4, Windows 98 Resource Kit, Windows 2000 Support Tools
- Introduced in Windows XP Professional Edition
- Also used in UNIX to send a process any signal, the “Terminate” signal is merely the default
-
curlandwgetaliases are absent from PowerShell Core, so as to not interfere with invoking similarly named native commands.
| Extension | Description |
|---|---|
| .ps1 | Script file[111] |
| .psd1 | Module’s manifest file; usually comes with a script module or binary module[112] |
| .psm1 | Script module file[113] |
| .dll | DLL-compliant[a] binary module file[114] |
| .ps1xml | Format and type definitions file[49][115] |
| .xml | XML-compliant[b] serialized data file[116] |
| .psc1 | Console file[117] |
| .pssc | Session configuration file[118] |
| .psrc | Role Capability file[119] |
| Application | Version | Cmdlets | Provider | Management GUI |
|---|---|---|---|---|
| Exchange Server | 2007 | 402 | Yes | Yes |
| Windows Server | 2008 | Yes | Yes | No |
| Microsoft SQL Server | 2008 | Yes | Yes | No |
| Microsoft SharePoint | 2010 | Yes | Yes | No |
| System Center Configuration Manager | 2012 R2 | 400+ | Yes | No |
| System Center Operations Manager | 2007 | 74 | Yes | No |
| System Center Virtual Machine Manager | 2007 | Yes | Yes | Yes |
| System Center Data Protection Manager | 2007 | Yes | No | No |
| Windows Compute Cluster Server | 2007 | Yes | Yes | No |
| Microsoft Transporter Suite for Lotus Domino[120] | 08.02.0012 | 47 | No | No |
| Microsoft PowerTools for Open XML[121] | 1.0 | 33 | No | No |
| IBM WebSphere MQ[122] | 6.0.2.2 | 44 | No | No |
| IoT Core Add-ons[123] | 74 | Unknown | Unknown | |
| Quest Management Shell for Active Directory[124] | 1.7 | 95 | No | No |
| Special Operations Software Specops Command[125] | 1.0 | Yes | No | Yes |
| VMware vSphere PowerCLI[126] | 6.5 R1 | 500+ | Yes | Yes |
| Internet Information Services[127] | 7.0 | 54 | Yes | No |
| Windows 7 Troubleshooting Center[128] | 6.1 | Yes | No | Yes |
| Microsoft Deployment Toolkit[129] | 2010 | Yes | Yes | Yes |
| NetApp PowerShell Toolkit[130][131] | 4.2 | 2000+ | Yes | Yes |
| JAMS Scheduler – Job Access & Management System[132] | 5.0 | 52 | Yes | Yes |
| UIAutomation[133] | 0.8 | 432 | No | No |
| Dell Equallogic[134] | 3.5 | 55 | No | No |
| LOGINventory[135] | 5.8 | Yes | Yes | Yes |
| SePSX[136] | 0.4.1 | 39 | No | No |
![]()
Wikiversity has learning resources about PowerShell
- PowerShell on GitHub
- Windows PowerShell Survival Guide on TechNet Wiki
It’s hard to leave behind a trusted tool in IT, but there are times when moving ahead requires letting go.
Out of the box, Visual Studio Code is a general-purpose code editor. It doesn’t flex its strengths until you install extensions for your language of choice. In this article, we’ll walk through how to install and configure the official PowerShell extension, cover the features it adds, how to debug PowerShell code and perform some basic Git interaction. By the end, you’ll be equipped to fully depend on VS Code for your PowerShell development needs.
How to add the PowerShell extension to Visual Studio Code
First, if you don’t have VS Code installed, you can download it for your operating system here. While all the examples in this article were run on Windows, the experience is cross-platform and applies to both Linux and MacOS running PowerShell 7. After installation, open it and select your theme of choice.
Next, click on the Extensions option in the sidebar and then search for PowerShell. Click on the Install button for the PowerShell extension from Microsoft.

The first thing you’ll be presented with is a walkthrough. If you appreciate guided introductions, it is recommended to try it to get familiar with the recent updates.
At the bottom you should notice a new terminal window called PowerShell Extension and the command explorer should show on the sidebar. That will be a familiar sight if you are coming from Windows PowerShell ISE.
If you go to File > Settings and then expand Extensions > PowerShell, you’ll find the settings for the PowerShell extension. For example, if you use the Format on Save setting (Text Editor > Formatting), there are several options for how the system automatically formats your code. My favorite is to enable Code Formatting: Auto Correct Aliases for VS Code to replace aliases whenever you hit save.
https://youtube.com/watch?v=apasCOHOdhE%3Fautoplay%3D0%26modestbranding%3D1%26rel%3D0%26widget_referrer%3Dhttps%3A
How to use the PowerShell extension in VS Code
In VS Code, if you open a .ps1 file, VS Code automatically sets the language to PowerShell. If you open a new, unsaved file you have the option to select a language.
Clicking on Select a Language will open the command palette for you to select PowerShell.
foreach ($proc in (gps)){if($proc -ne $null){$proc.Name}}
This is how VS Code uses the PSScriptAnalyzer code analysis tool to help you write better code. For example, the if expression $proc -ne $null should be $null -ne $proc.
The IntelliSense feature in VS Code is an AI feature that offers coding suggestions. For example, if you remove line three and start typing $pr, then IntelliSense will provide a dropdown menu of possible autocompletes.

And then, once you select $proc, you can add a period and see the available properties.

IntelliSense also works with cmdlets. If you start to type a cmdlet name, then you’ll see a similar dropdown with several options.

When you get further along in your coding experience with VS Code, you can tap into the IntelliCode feature, which is another AI-based enhancement that offers suggestions based on the code you’ve written to speed up the scripting process.
How to debug PowerShell in VS Code
Debugging in VS Code is similar to the process in other integrated development environments. If we want to run a script and pause it on certain lines, select the line and press F9 or click just to the left of the line number.

If you press F5 or go to the Run menu and select Start Debugging, the script will run until it hits the breakpoint and then it will pause and you can examine the variables.

In this case, I want to examine the $proc variable, so I’ll expand Script and scroll down. You’ll see that the first process running on my computer is 1Password.

I can step the script, meaning move it to the next breakpoint, by either pressing F5 or the step icon. In this case it will continue to break inside the foreach loop until it runs out of items being returned by Get-Process.
If you prefer to check the variables at a terminal, you can do so by typing in the variable name in the integrated terminal.

In this case, I’ve stepped through the code several additional times.
You also have access to other PowerShell debugger commands. You can continue stepping with the c command. For the full list of debugger commands, have a look at official documentation at this link.
When finished debugging, you can stop by pressing the Stop button or Shift-F5.
How to integrate VS Code with Git
Once you have a script written, debugged and ready to save, then you’ll want to commit it to Git, which VS Code integrates with natively. First, install Git at this link, then close and reopen VS Code.
With a new instance of VS Code open, use the Open Folder option to open an existing cloned Git repository or you can use the git command to initialize one with the git init command.
Once in that repository directory, I’ll go ahead and add a file, update it with my script contents, and then save it. You should see a 1 icon over the source control icon on the sidebar.

If you click on that icon, it opens the Source Control view where you can enter in a commit message about your change and commit your code.

git config user.name "Anthony Howell"
git config user.email "[email protected]"If you have a cloned git repository from a service such as GitHub or a remote server, then you have the option to Sync or Publish Branch if it’s a new branch.
Why it’s time to try VS Code for PowerShell scripting
Microsoft has invested a lot of effort to make PowerShell in VS Code a first-class citizen and has a team dedicated to maintaining the PowerShell extension. If you encounter an issue or find a bug with the extension, you can open a GitHub issue in the official repository. Fortunately, the extension is solid so your coding experience should go smoothly.
If you still use Windows PowerShell ISE, you should try VS Code for your PowerShell scripts. Another advantage of learning PowerShell in VS Code is it allows you to easily pivot into writing Terraform or even Python in VS Code so you can expand your skills in other areas.
Anthony Howell is an IT expert who is well-versed in multiple infrastructure and automation technologies, including PowerShell, DevOps, cloud computing, and the Windows and Linux operating systems.
- Windows Server 2022 with Windows PowerShell 5.1 and PowerShell 7.2
- Windows Server 2019 with Windows PowerShell 5.1 and PowerShell 7.2
- macOS 11 with PowerShell Core 7.2
- Ubuntu 20.04 with PowerShell Core 7.2
Installing the PowerShell extension
The PowerShell extension can be installed from the Visual Studio Code Marketplace by clicking the
Install Button. You can also install the PowerShell extension from within VS Code by opening
the Extensions view with keyboard shortcut (Windows, Linux ), typing PowerShell,
and selecting the PowerShell extension:

Major features
- Syntax highlighting
- Advanced built-in code snippets
- IntelliSense for cmdlets and more
- Problems reported by PowerShell Script Analyzer
- Go to Definition of cmdlets, variables, classes and more
- Find References of cmdlets, variables, classes and more
- Document and Workspace Symbol Navigation
- Symbol-based Outline View
- Run selected PowerShell code in current terminal using
- Launch online help for the symbol under the cursor using Ctrl + F1
- PowerShell Debugger integration
- An Extension Terminal that can interact with the debugger (try
Set-PSBreakpoint!) - PowerShell ISE theme findable in the theme picker
- Also try ISE mode using (Windows, Linux ) then search for “Enable ISE Mode”
Debugging
Multi-version support
Or run the PowerShell: Show Session Menu command from the Command Palette
( (Windows, Linux )).
CodeLens support
CodeLenses are a VS Code feature to provide actionable, contextual information that’s displayed
within the source code.
CodeLens features include:
Pester Run tests and Debug tests.

Pester symbol support

Function, variable, class, and other symbol references
CodeLens reference support shows the number of times a symbol is referenced within your
code and allows you to jump to specific references.
PSScriptAnalyzer integration
The PowerShell extension includes PSScriptAnalyzer by default, and automatically performs
analysis on PowerShell script files you edit in VS Code.
PSScriptAnalyzer comes with a collection of built-in rules that check various aspects of
PowerShell source code such as presence of uninitialized variables, usage of PSCredential type,
usage of Invoke-Expression, and others. The module also allows you to include or exclude specific
rules.
To disable PSScriptAnalyzer, open your settings ( (Windows, Linux )), browse
Extensions, select the PowerShell extension, and deselect the checkbox for Script
Analysis: Enable (powershell.scriptAnalysis.enable).

PSScriptAnalyzer also provides code formatting. You can invoke automatic document formatting
with the Format Document command or the ( (Windows , Linux )) keyboard shortcut.
Pester integration
Plaster integration
Plaster is a template-based file and project generator written in PowerShell. Its purpose is
to streamline the creation of PowerShell module projects, Pester tests, DSC Configurations and more.
The PowerShell extension allows the creation of new Plaster projects using the PowerShell: Create
New Project from Plaster Template command from the Command Palette
( (Windows, Linux )).

PowerShell extension settings
You can customize VS Code settings from the File > Preferences > Settings menu item.
You can also select the gear icon located in the lower left corner of the Activity Bar.

Types.ps1xml and Format.ps1xml files
- Syntax error reporting
- Schema validation
- Tag and attribute completion
- Autoclose tags
- Symbol highlighting
- Document folding
- Document symbols and outline
- Renaming support
- Document formatting
Example scripts
You can also open the examples from the Command Palette ( (Windows, Linux )) with
the PowerShell: Open Examples Folder command.

Additional resources
There are more detailed articles in the PowerShell documentation. Start with Using VS Code.
Check out the troubleshooting guide for answers to common questions.
Testing new features and providing feedback

If you find a bug, open an issue and revert to the stable version while we fix it.
Use this to retrieve a single item. Throws an error if the item does not exist.
Use when Sitecore
query:orfast:is required. May return more than 1 item.
More than one item matches the criteria so show them all. | |||||||
The specified database will be used. Requires the ID to be set. | |||||||
Parent item to receive the copied item. | |||||||
Unauthorized access errors will be suppressed | |||||||
Forces the new item to use a specified GUID | |||||||
Matches the item by ID. | |||||||
Specifies the languages to include. | |||||||
Specifies the parent item. | |||||||
Specifies the item should be deleted rather than recycled. | |||||||
Matches the items by an XPath query. | |||||||
Initiates the default workflow, if any. | |||||||
Options flag used when copying from one database to another. | |||||||
Matches the item by ItemUri. | |||||||
Specifies the version to include. | |||||||
Specifies the command should include the parent item. |
Legend: “–” – not applicable; “✓” – available.
If you have retrieved your items directly using the Sitecore API you can still add the nice wrapper. You can do that by piping them through the Initialize-Item command. We’ll show an example of this later.
Check out some performance details when using different methods of querying items on the Sitecore StackExchange.
Get-Item : by Path
Name Children Languages Id TemplateNameAs you may have noticed, the /sitecore portion of the path is unnecessary. This is because the Sitecore item is represented by the root item of the drive master: and is therefore optional.
Let’s have a look at the equivalent code in C#.
The above will return the latest version of the item in your current language. But what if you want the item in another language? No problem!
DisplayName Language ID Version TemplateNameI’ve formatted the output above to show you that indeed the right language was returned. The command supports wildcards for both -Language and -Version parameters. You may have also noticed that the forward and backward slashes can be used interchangeably.
DisplayName Language ID Version TemplateNameNotice that the item with language en-US at its third version.
DisplayName Language ID Version TemplateNameYou can see that specifying the language and version using the wildcard will retrieve all possible variants of an item. The wildcard can also include a partial match like en-*. The use of that filter would return all items in the English language, ignoring the region.
Get-ChildItem : by Path
DisplayName Language ID Version TemplateNameGet-Item : Sitecore query
It’s not always most efficient to operate on items by traversing the tree using Get-ChildItem. This is especially true if you need to work on large trees but need to select only a few items (e.g. a specific template). For this we’ve introduced support for the Sitecore query within our provider.
Important to note that the query format sometimes requires the use of a
#before and after paths when they contain reserved keywords or spaces.Workaround found here on Sitecore Stack Exchange.
Name Children Languages Id TemplateNameDisplayName Language ID Version TemplateNameGet-Item : Sitecore Fast query
Get-Item : by XPath
# Retrieve the items with Axes and a given context item.# Retrieve the items using the Query class and context item.# Retrieve the items by prepending the context path to the query.Get-Item : by Id
Name Children Languages Id TemplateNameGet-Item : by Uri
The Uri encodes the language and version within the path.
Name Children Languages Id TemplateNameHKLM: – The registry provider for HKEY_LOCAL_MACHINE.
C: – The filesystem provider for the C drive.
Get-Item : select properties
Name ID __Owner __SecurityName ID BaseTemplateName : kitten1Alt : YayWidth : Height : Extension : jpgSize : Name : Calculate Statistical RelevancyLast run : Items :Get-Item : properties with field type
Note: You can use ._ and .PSFields to gain access to the typed field.
Anchor :Class :IsInternal : TrueIsMediaLink : FalseLinkType : internalMediaPath :QueryString :Target :TargetItem : Sitecore.Data.Items.ItemTitle :Url :Root : linkXml : Get-Item : then change item properties
Note: The above example may also be written in the ISE where no console prompt is visible.
The previous examples work but are not the most efficient ways to change item content. The items returned by the provider expose the Sitecore item fields as automatic PowerShell properties.
If the property name on the data template contains a space, such as `Closing Date`, then you will need to wrap the field name in quotes (single or double).
"I Like Turtles"This technique may be used for a wide variety of property types.
If you need to dynamically reference a property via a property name that is stored in a variable, there are numerous ways to reference it.
# All variations will workThere are a other hidden gems in automated PowerShell properties. For example, if we detect that the field is a Date or Datetime field, we will return System.DateTime typed value from a field rather than the System.String Sitecore stores internally.
# Monday, April 07, 2008 1:59:00 PM# Tuesday, March 17, 2020 12:00:00 PMGreat we’ve just changed it! Our property handlers take care of all the necessary usages of .Editing.BeginEdit and .Editing.EndEdit. This method can be applied for a variety of field types such as GeneralLink and Image.
Easy enough, isn’t it? Let SPE detect the field type for you and worry about what to call! Now let’s assign a content item to GeneralLink.
What about fields that accept lists of items? We’ve got your back here as well.
Let’s see how our item looks in the Content editor after all the assignments that we’ve just performed:
Great! Looks like it worked.
Those little improvements make your scripts much more succinct and understandable. Try it for yourself!
When not to use the automated properties?
Choosing this way is situational and will usually only be required if you’re working with a large volume of data. In those cases you might also want to introduce the Sitecore.Data.BulkUpdateContext technique.
If you have reached this point, then you are clearly a nerd and want to access using the raw Sitecore API.
# Get the root node using Get-Item, then a call to Axes.Copy-Item : to a new destination
You will find yourself one day in need of copying items on a small to large scale. The Copy-Item command will likely meet the need.
Copy-Item -Path "master:\content\home\Sample Item\Sample Item 1" -Destination "master:\content\home\Sample Item\Sample Item 2"Note: The item name will match just as you type it in the command. Lowercase name in the destination will result in an item with a lowercase name.
Move-Item : to a new destination
There is a always a better way to do something. Moving items en masse is certainly one that you don’t want to do by hand. If the destination item exists the moved item will be added as a child. If the destination item does not exist the source item will be renamed when moved.
"master:\content\home\sample item\Sample Item 1""master:\content\home\sample item 2\""master:\content\home\sample item\Sample Item 3"Name Children Languages Id TemplateName"master:\content\home\sample item\Sample Item 4"Name Children Languages Id TemplateName"Sample Item 3"Name Children Language Version Id TemplateNameNote: The New-Item command was passed to Format-Table -Autosize to improve the formatting.
Remove-Item : permanently
"master:\content\home\sample item\Sample Item 3"Appendix
Downloads are hosted on Github
Legend: “–” – not supported; “✓” – supported.
N.X : Full N.X release – This refers to the package used by Standalone and CM roles. This includes what is required to see the PowerShell ISE, Console and their associated services.
N.X Minimal : Server-side remoting only – This refers to the package with only files. Useful for remotely connecting to SPE.
N.X Authorable Reports : Additional reports and tools – This package is a sublemental installation to the full version with additional reports. With version 6.0 this package is no longer needed as the reports are included with the full release.
N.X Remoting : SPE Remoting module for CI/CD – This provides a Windows PowerShell module for connecting to SPE remotely. Use in combination with the full or minimal packages.



