M365 PowerShell Management

To connect with the SharePoint Online Management Shell (PowerShell)

PowerShell 5 used for below commands

Check to see if the SharePoint module is already installed:

Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version 

Install the SharePoint module (from an administrator terminal):

Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Scope AllUsers

Ensure the module is up-to-date (from an administrator terminal):

Update-Module -Name Microsoft.Online.SharePoint.PowerShell

Login to the SharePoint Management Console (from a non-administrator terminal). The URL can be found by logging into admin.microsoft.com, navigating to the SharePoint management site, and getting the company admin url from the nav bar (e.g. https://yourcompany-admin.sharepoint.com.:

Connect-SPOService -Url https://yourcompany-admin.sharepoint.com

SharePoint Tenant Level Config

List of commandlets: Microsoft.Online.SharePoint.PowerShell Module | Microsoft Learn

To get the tenant level config:

Get-SPOTenant

To find the objects associated with settings in the UI:

Get-SPOTenant | Out-File -FilePath before.txt
# Make a change to the setting
Get-SPOtenant | Out-File -FilePath after.txt
# Compare file to identity the configuration
compare-object (get-content before.txt) (get-content after.txt)

Set-SPOTenant (Microsoft.Online.SharePoint.PowerShell) | Microsoft Learn

Once the config is identified, the Set-SPOTenant commandlet can be used to change the setting. For example to change SharePoint and OneDrive sharing settings:

Set-SPOTenant -SharingCapability ExistingExternalUserSharingOnly

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *