O365 PowerShell Stuff

Install Exchange Online Management Module

Install-Module -Name ExchangeOnlineManagement

Connect to Exchange Online

Connect-ExchangeOnline -UserPrincipalName user@domain.com

Another method

Store your O365 credentials in a variable

$msolcred = get-credential

Connect to O365

connect-msolservice -credential $msolcred

Change UPN of a user in O365

Set-MsolUserPrincipalName -UserPrincipalName current@domain.onmicrosoft.com -NewUserPrincipalName newusername@domain.com

Hide Group From Global Address List

Set-UnifiedGroup -Identity "Name" -HiddenFromAddressListsEnabled $true

Connect to Sharepoint Online

First you can check if you have already installed the SharePoint Online Management Shell by running the following command in administrative mode in PowerShell:

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

If your operating system is using PowerShell 5 or newer, you can also install the SharePoint Online Management Shell by running the following command in administrative mode:

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

If you don’t have administrative privileges on the system, you can install the SharePoint Online Management Shell only for the current user by running the following command:

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

To ensure you have all available cmdlets, you should always make sure the module is up to date. You can update the SharePoint Online Management Shell by running the following command in administrative mode:

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

To connect with a user name and password

Run the following command at the SharePoint Online Management Shell command prompt:

Connect-SPOService -Url https://contoso-admin.sharepoint.com -Credential admin@contoso.com

When prompted with the Windows PowerShell credential request dialog box, type the password for the SharePoint admin account.

To connect with multifactor authentication (MFA)

Run the following command at the SharePoint Online Management Shell command prompt:

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

When prompted with the Microsoft SharePoint Online Management Shell dialog box, type the account name and password for a SharePoint administrator account, and then click Sign in.

Follow the instructions in the Microsoft SharePoint Online Management Shell dialog box to provide the additional authentication information, such as a verification code, and then click Sign in.

You are now ready to use SharePoint Online commands.

Fix Sharepoint Online backup (Veeam) error ‘Site was moved to another URL’

Connect to Sharepoint Online admin shell and enter the URL of the redirect site that has to be removed:

Remove-SPOSite -Identity https://contoso.sharepoint.com/sites/OldWebsite