Introduction to SharePoint Online Management Shell (.NET Framework and .NET Core Versions)

The SharePoint Online Management Shell is a command-line tool that provides a set of PowerShell cmdlets for managing SharePoint Online environments. With two distinct versions, one built on .NET Framework (Windows-only) and the other on .NET Core (cross-platform), administrators have the flexibility to choose the best option depending on their environment.

In this article, we will cover both the .NET Framework and .NET Core versions, along with installation instructions and details on how to update the modules.

SharePoint Online Management Shell (.NET Framework)

The .NET Framework version of the SharePoint Online Management Shell is designed for Windows-based systems and requires PowerShell 5.1 or newer, which comes pre-installed on most modern Windows operating systems.

Key Features:

  • Windows-Only: Built on .NET Framework and only runs on Windows.
  • Automation: Automate complex or repetitive tasks in SharePoint Online environments.
  • Admin-Level Management: Manage user permissions, site collections, and more.
  • Legacy Compatibility: Supports traditional Windows PowerShell environments.

Prerequisites:

  • Windows PowerShell 5.1 or higher: Pre-installed on Windows 10/11 and Windows Server.
  • Global Administrator or SharePoint Administrator role.

Installation Steps (Windows with .NET Framework):

  1. Open Windows PowerShell with Administrator privileges.
  2. Install the SharePoint Online Management Shell module using the following command:
   Install-Module -Name Microsoft.Online.SharePoint.PowerShell
  1. During installation, you might see a prompt stating that the module is from an untrusted repository. To proceed:
  • Press A to accept and install from the PSGallery for all future modules.
  • Or press S to proceed with the installation just this one time.
   Repositório não confiável
   Você está instalando módulos de um repositório não confiável. Se você confiar nesse repositório, altere seu valor 
   InstallationPolicy. Basta executar o cmdlet Set-PSRepository. 
   Tem certeza de que deseja instalar os módulos de 'PSGallery'?
   [S] Sim  [A] Sim para Todos  [N] Não  [T] Não para Todos  [U] Suspender  [?] Ajuda (o padrão é "N"):
  1. To check if the module was successfully installed:
   Get-Module -ListAvailable -Name Microsoft.Online.SharePoint.PowerShell
  1. Updating the Module:
    If a newer version of the module is available, you can update it by adding the -Force parameter. This will install the latest version alongside the existing one.
   Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force
  1. Connecting to SharePoint Online:
    After installation, connect to your SharePoint Online tenant by running:
   Connect-SPOService -Url https://<your-tenant-name>-admin.sharepoint.com

Enter your administrator credentials when prompted.

SharePoint Online Management Shell (.NET Core)

The .NET Core version of the SharePoint Online Management Shell allows administrators to manage SharePoint Online environments from any operating system, including Windows, macOS, and Linux. This version leverages PowerShell Core (7.x) and the .NET Core runtime, providing flexibility for modern development environments.

Key Features:

  • Cross-Platform: Works on Windows, macOS, and Linux.
  • Modern Development: Ideal for DevOps workflows and automation.
  • Bulk Management: Manage multiple users, sites, and permissions efficiently.
  • Performance: Better performance due to the use of .NET Core.

Prerequisites:

  • PowerShell Core (7.x): Installed on your system.
  • .NET Core Runtime: The latest version of the .NET Core runtime.
  • Global Administrator or SharePoint Administrator role.

Installation Steps (Cross-Platform with .NET Core):

  1. Install PowerShell Core (7.x):
  • Windows:
    Download PowerShell Core from the official GitHub page. After installation, run the following command to check the version: pwsh -Version
  • macOS:
    Install PowerShell Core using Homebrew: brew install --cask powershell
  • Linux (Ubuntu example):
    Install PowerShell Core via apt: sudo apt-get update sudo apt-get install -y powershell
  1. Install the SharePoint Online Management Shell Module:
    Once PowerShell Core is installed, use this command to install the SharePoint Online Management Shell module:
   Install-Module -Name Microsoft.Online.SharePoint.PowerShell -AllowClobber

You may see the same prompt regarding an untrusted repository. Press A to install from PSGallery or S for a one-time installation.

  1. Verifying the Installation:
    To verify if the module has been installed:
   Get-Module -ListAvailable -Name Microsoft.Online.SharePoint.PowerShell
  1. Connect to SharePoint Online:
    To manage your tenant, connect to the SharePoint Online service:
   Connect-SPOService -Url https://<your-tenant-name>-admin.sharepoint.com

Provide your credentials when prompted.

Updating and Managing Module Versions

Occasionally, you might have an older version of the Microsoft.Online.SharePoint.PowerShell module installed, and you will want to update to the latest version. The PowerShell -Force parameter allows you to install the latest version side by side with older versions.

For example, if you receive a warning message like the one below:

AVISO: A versão '16.0.23019.12000' do módulo 'Microsoft.Online.SharePoint.PowerShell' já está instalada...
Para instalar a versão '16.0.25311.12000', execute Install-Module e adicione o parâmetro -Force.

You can update the module with:

Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force

This will install the new version without removing the older one, allowing you to manage multiple module versions.

Common Cmdlets for Managing SharePoint Online

After connecting to your SharePoint Online tenant, here are some common cmdlets you can use:

  • Create a new site collection:
   New-SPOSite -Url https://<your-tenant-name>.sharepoint.com/sites/sitename -Owner user@domain.com -StorageQuota 1024 -Title "Site Title"
  • Delete a site collection:
   Remove-SPOSite -Identity https://<your-tenant-name>.sharepoint.com/sites/sitename
  • Assign a site collection administrator:
   Set-SPOUser -Site https://<your-tenant-name>.sharepoint.com/sites/sitename -LoginName user@domain.com -IsSiteCollectionAdmin $true
  • Remove a user:
   Remove-SPOUser -Site https://<your-tenant-name>.sharepoint.com/sites/sitename -LoginName user@domain.com
  • List all users in a site collection:
   Get-SPOUser -Site https://<your-tenant-name>.sharepoint.com/sites/sitename
  • View storage quota information:
   Get-SPOSite -Identity https://<your-tenant-name>.sharepoint.com/sites/sitename -Detailed

Troubleshooting and Known Issues

  1. Untrusted Repository Warnings:
  • When installing from the PSGallery for the first time, use Set-PSRepository -Name PSGallery -InstallationPolicy Trusted to mark it as trusted permanently.
  1. Installation Failures:
  • Ensure that PowerShell Core (for .NET Core) or Windows PowerShell (for .NET Framework) is installed and up to date.
  1. Cannot Connect to Tenant:
  • Ensure that you have the correct tenant URL and proper administrator privileges.
  1. Command Errors:
  • If you encounter issues with cmdlets, verify that you have the latest module version by running: Update-Module -Name Microsoft.Online.SharePoint.PowerShell

Conclusion

Both the .NET Framework and .NET Core versions of the SharePoint Online Management Shell offer robust tools for managing your SharePoint Online environment. The .NET Framework version is ideal for administrators working within a Windows environment, while the .NET Core version offers cross-platform capabilities, making it suitable for modern, cloud-based, and hybrid development environments. By choosing the right version for your needs, you can automate

Edvaldo Guimrães Filho Avatar

Published by

Categories:

Leave a comment