PowerShell for SharePoint Online Toolset
In my last article at Petri.com, I introduced some of the usage scenarios we can face when managing SharePoint Online (SPO) using PowerShell. In this article, I will describe some of the Tools (Figure 1) we can use to run our SPO PowerShell Scripts.
Figure 1 — PowerShell for SPO Toolset
So, let’s talk a little bit about each of the tools represented in Figure 1:
Windows PowerShell refers not only to a command-line shell tool for Windows but also to a scripting language that has become a standard to manage almost any Microsoft platform (OnPremises and in the Cloud). You can execute SPO default cmdlets in the native Windows PowerShell shell whenever you first install the SPO Management Shell. Note: You can download last SPO Management Shell from here.
Figure 2 — Executing SPO Cmdlets in Windows PowerShell
Of course, you can also execute any PowerShell Script that uses any of the SPO APIs:
- Client Side Object Model (CSOM)
- SPO REST API
- Microsoft Graph API
SPO Management Shell
SPO Management Shell is the default PowerShell shell provided by Microsoft to execute latest SPO cmdlets against a SPO tenant. It’s updated quite often by Microsoft (at the time of writing, last update available was release on the 21st of December). This means that we have to keep an eye on the usual channels used by the SPO Dev Team to communicate that a new version of the SPO Management Shell is available. From there, we can update it on our machines. Note: Microsoft does not currently provide a built-in mechanism to update the SPO Management Shell with last available update.
Windows PowerShell ISE
The Windows PowerShell Integrated Scripting Environment (ISE) is just a host application for Windows PowerShell that is available by default in modern Windows OS such as Windows 10 or Windows Server 2016. Some of the features of Windows PowerShell ISE are the following:
- It’s “almost” a development environment for PowerShell providing features such as Debugging, Intellisense, or Code Coloring among others.
- It allows to run PowerShell cmdlets and write, test, and debug PowerShell scripts.
- Each new ISE version released by Microsoft adds new features and improvements.
As happens with previous tools, we can use Windows PowerShell ISE to execute SPO cmdlets or just write and execute PowerShell scripts where SPO APIs are used.
Figure 3 — Running in Microsoft PowerShell ISE a PowerShell Script that Uses CSOM SPO API
Visual Studio 2017
Visual Studio is still the most used IDE (Integrated Development Environment) for many .NET developers and it also allows to write, test, and debug PowerShell scripts and modules. PowerShell support in Visual Studio is provided by means of the PowerShell Tools for Visual Studio that are available in the Visual Studio Market Place:
Some features provided by PowerShell Tools for Visual Studio are:
- They enable project templates and project items templates in Visual Studio to Create projects for PowerShell scripts and modules.
- They enable to execute PowerShell Scripts and Commands right from Visual Studio.
- They provide the ability to edit, run, and debug PowerShell scripts locally and remotely using the Visual Studio debugger.
- You can take advantage of all the developer features available in Visual Studio for your PowerShell scripts and modules: Visual Studio’s locals, watch, call stack, etc.
Again, in Visual Studio it is possible to execute standard SPO cmdlets and also write, test, and debug PowerShell Scripts where SPO APIs are used.
Figure 4 — Using SPO Standard Cmdlets in Visual Studio
Visual Studio Code
If Visual Studio is still the most used IDE by most .NET Developers, Visual Studio Code is also becoming popular among developers. As happens with Visual Studio, Visual Studio Code allows to write, test, and debug PowerShell scripts and modules. This is possible thanks to the PowerShell extensions for Visual Studio Code available also at the Visual Studio marketplace:
Once you install the PowerShell extensions for Visual Studio Code, you get the following features:
- Syntax highlighting
- Code snippets
- IntelliSense for cmdlets and more
- Rule-based analysis provided by PowerShell Script Analyzer
- Go to Definition of cmdlets and variables
- Find References of cmdlets and variables
- Document and workspace symbol discovery
- Run selected selection of PowerShell code using F8
- Launch online help for the symbol under the cursor using Ctrl+F1
- Local script debugging and basic interactive console support
As happens with Visual Studio, Visual Studio Code allows to execute not only scripts where standard SPO PowerShell cmdlets and/or SPO APIs.
Figure 5 — Running a PowerShell Script for SPO in Visual Studio Code
Other PowerShell Tools for SPO
Additionally, to the PowerShell Tools for SPO provided by Microsoft, there are other third-party tools that could be used to manage SPO. The following are examples of those third-party tools (some are free, but others are not):
- Dell PowerGUI – IDE – Freeware
- Sapiens Technologies PowerShell Studio 2017
- Sapiens PrimalScript 2017
- Specops Command
We can work with PowerShell for SPO by using any of the development environments provided by Microsoft. If you ask my recommendation about what tool to use, I would say Windows PowerShell ISE or Visual Studio Code. Finally, there are also third-party tools to run PowerShell scripts and modules for SPO.
More in PowerShell
How to Check Your PowerShell Version
May 4, 2022 | Michael Reinders
How to Download a File using PowerShell
Apr 21, 2022 | Michael Reinders
How to Write and Run a PowerShell Script File on Windows 11
Apr 4, 2022 | Ivan Mirchev
Microsoft’s New PowerShell Crescendo Tool Facilitates Native Command-Line Wraps
Mar 21, 2022 | Rabia Noureen
Get-AdUser: How to Audit Active Directory Users with PowerShell
Mar 3, 2022 | Michael Reinders
The Top 10 PowerShell Commands That You Should Know
Feb 17, 2022 | Michael Reinders
Most popular on petri