Office 365 PowerShell Troubleshooting: quick guide
Powershell is a mighty tool for Office 365 as it brings more possibilties, ability to pull loads of data or bulk-update users/sites/mailboxes.
While you are working with it, you may encounter several errors. Below you can find a list of the most common ones and suggested fixes. Some of the error messages are not unique and both the reason and the fix for them can differ.
Overview
At the bottom of the table, you can scroll to the right for displaying the right column.
Error Message
Possible Explanation
What to do?
Files cannot be loaded because the running of scripts is disabled on this system. Please provide a valid certificate with which to sign the files.
The execution policy is set to "restricted". You can verify it using Get-ExecutionPolicy cmdlet
Set-ExecutionPolicy unrestricted -or- Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\
Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.
Run Powershell as Administrator
CMDLET : The term 'CMDLET' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
- You did not install the appropriate module, e.g. SharePoint Online Management Shell for cmdlets involving SPO like Get-SPOSite; Windows Azure Active Directory Module for cmdlets involving MSOL like Get-MSOLUser
- You did not connect to Exchange Online for cmdlets such as Get-Mailbox You misspelled the name of the cmdlet. Verify its name. Use Tab to fill-in the cmdlets automatically.
Install the correct module and run it as an Administrator or verify the connection to Exchange Online.
get- : The term 'get-' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
Powershell cmdlets follow VERB-NOUN pattern. You are missing a noun.
Check if there is no space after "-" sign
Get-MsolContact : You must call the Connect-MsolService cmdlet before calling any other cmdlets.
Most probably you have installed the correct module, but you need to run connect cmdlet first.
Connect-Msolservice
Get-SPOSite : No connection available. Use Connect-SPOService before running this CmdLet.
Most probably you have installed the correct module, but you need to run connect cmdlet first.
Connect-SPOService
The user name or password is incorrect. Verify your user name, and then type your password again.
Wrong credentials.
Verify the credentials. Try to log with them in the browser
The sign-in name or password does not match one in the Microsoft account system.
Wrong credentials.
Verify the credentials. Try to log with them in the browser
connect-sposervice : Current site is not a tenant administration site.
You have entered wrong url. The admin Center url looks like https://tenant-admin.sharepoint.com
Verify if the url you entered looks like https://tenant-admin .sharepoint.com
A positional parameter cannot be found that accepts argument '-'.
Incorrect syntax, e.g. When you write get-sposite - identity instead of get-sposite -identity
Verify if there is any empty space after "-" sign. If yes, remove it.
Cannot bind parameter 'Identity'. Cannot convert value "-" to type "Microsoft.Online.SharePoint.PowerShell.
SpoSitePipeBind". Error: "SpoSitePipeBind Url"
Incorrect syntax, e.g. When you write get-sposite - identity instead of get-sposite -identity
Check the spaces and dashes.
New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : [ClientAccessServer=AMSPR04CA0034,BackEndServer=
am3pr02mb262.eurprd02.prod.outlook.com,RequestId=
a82571e0-bda3-4d0f-8c63-11937a382083,TimeStamp=8/27/2015 11:43:09 AM]
Access Denied
Wrong credentials.
Verify the credentials
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Supply a non-null argument and try the command again.
Is Import-Pssession $THISVALUE the same as $THISVALUE=new-pssession
CMDLET : The term 'CMDLET' is not recognized as the name of a cmdlet
CMDLET : The term 'CMDLET' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
Possible Explanation
- You did not install the appropriate module, e.g. SharePoint Online Management Shell for cmdlets involving SPO like Get-SPOSite; Windows Azure Active Directory Module for cmdlets involving MSOL like Get-MSOLUser
- You did not connect to Exchange Online for cmdlets such as Get-Mailbox
- You misspelled the name of the cmdlet. Verify its name. Use Tab to fill-in the cmdlets automatically.
What to do?
- Install the correct module and run it as an Administrator
- Verify the connection to Exchange Online (if that's what you want to use; do not verify EXO connection if you are trying to use SPO cmdlet)
- Check the spelling of the cmdlet
Running scripts disabled
Files cannot be loaded because the running of scripts is disabled on this system. Please provide a valid certificate with which to sign the files.
Possible Explanation
The execution policy is set to "restricted". You can verify it using Get-ExecutionPolicy cmdlet
What to do?
Set-ExecutionPolicy unrestricted -or- Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy : Access to the registry key is denied.
Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\PowerShell\1\ ShellIds\Microsoft.PowerShell' is denied.
What to do?
Run Powershell as Administrator
get- : The term 'get-' is not recognized
get- : The term 'get-' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
Possible Explanation
Powershell cmdlets follow VERB-NOUN pattern. You are missing a noun.
What to do?
Check if there is no space after "-" sign
You must call the Connect-MsolService
Get-MsolContact : You must call the Connect-MsolService cmdlet before calling any other cmdlets.
Possible Explanation
Most probably you have installed the correct module, but you need to run connect cmdlet first.
What to do?
Connect-MsolService
No connection available. Use Connect-SPOService
Get-SPOSite : No connection available. Use Connect-SPOService before running this CmdLet.
Possible Explanation
Most probably you have installed the correct module, but you need to run connect cmdlet first.
What to do?
Connect-SPOService
The user name or password is incorrect
The user name or password is incorrect. Verify your user name, and then type your password again.
Possible Explanation
Wrong credentials.
What to do?
Verify the credentials. Try to log with them in the browser.
The sign-in name or password does not match one in the Microsoft account system.
The sign-in name or password does not match one in the Microsoft account system.
Possible Explanation
Wrong credentials.
What to do?
Verify the credentials. Try to log with them in the browser.
Current site is not a tenant administration site.
connect-sposervice : Current site is not a tenant administration site.
Possible Explanation
You have entered wrong url. The admin Center url looks like https://tenant-admin.sharepoint.com
What to do?
Verify if the url you entered looks like https://tenant-ADMIN.sharepoint.com
A positional parameter cannot be found that accepts argument '-'
A positional parameter cannot be found that accepts argument '-'.
Possible Explanation
Incorrect syntax. Most probably due to excessive spaces, e.g. when you write get-sposite - identity instead of get-sposite -identity. In general, there are no spaces after "-" sign in Powershell syntax.
What to do?
Verify if there is any empty space after any "-" sign. If yes, remove it.
Connecting to remote server outlook.office365.com failed
New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : [ClientAccessServer=AMSPR04CA0034,BackEndServer= am3pr02mb262.eurprd02.prod.outlook.com,RequestId= a82571e0-bda3-4d0f-8c63-11937a382083,TimeStamp=8/27/2015 11:43:09 AM] Access Denied
Possible Explanation
Incorrect credentials.
What to do?
Verify the credentials.
Cannot validate argument on parameter 'Session'
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Supply a non-null argument and try the command again.
or if a path was included, verify that the path is correct and try again.
What to do?
Is Import-Pssession $THISVALUE the same as $THISVALUE=new-pssession... ?