Forum Discussion
Yevhen Kryvun
May 17, 2017Copper Contributor
O365 Powershell error during global admin credentials validation
We are using Powershell script for validation O365 credentials (is it global admin O365 user or not). It was working fine for all cases except one. We received an error:
Connect-MsolService : Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown. At line:4 char:1 + Connect-MsolService -Credential $cred + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [Connect-MsolService], Mic rosoftOnlineException + FullyQualifiedErrorId : 0x800488F2,Microsoft.Online.Administration.Autom ation.ConnectMsolService
Also, we have verified that these credentials are credentials of O365 global admin user, there is no SSO and MFA enabled for this organization.
Powershell module is up-to-date. The script which is executed is next:
'Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking\n' '$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList' ' $username, $(convertto-securestring $password -AsPlainText -Force)\n' 'Connect-SPOService -Url "$admin_site_url" -Credential $cred\n'
and we are passing appropriate values in variables.
Is it possible that somewhere in Portal Azure this global admin user has disabled Powershell access for the account? Or this organization disabled Powershell access?
- Deleted
Can you please provide more info? And a suggestion you could use pnp powershell this has a lot of extra functionality
- Amo ZhangCopper Contributor
I saw this for several times. The exception is too generic. Probably wait for some seconds or minutes and try again and it is gone. Hope my experience helps you.