Quick Script to Test SharePoint Online Credentials

$principle = "USERNAME@SOMESHAREPOINT.COM"  
$password = 'PASSW0RT'  
$sharePointUrl = "https://SOMESHAREPOINT.COM/SitePages/Home.aspx"  

$credential=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $principle,$(ConvertTo-securestring $password -AsPlainText -Force)
$moduleName='Microsoft.Online.SharePoint.PowerShell'
if (!(get-module $moduleName -ea SilentlyContinue)){Install-Module -Name $moduleName -Force}
Connect-SPOService -Url $sharePointUrl -Credential $credential

Possible Errors:

# This error occurs if the SharePoint site has not automated login enabled

#Connect-SPOService : Cannot contact web site 'https://ORGNAME.sharepoint.com/' or the web site does not support
#SharePoint Online credentials. The response status code is 'Unauthorized'. The response headers are
#'X-SharePointHealthScore=3, X-MSDAVEXT_Error=917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+f
#irst+browse+to+the+web+site+and+select+the+option+to+login+automatically.,
#SPRequestGuid=, request-id=,
#MS-CV=n2lJ3FpgAABhdghow6/LIg.0, Strict-Transport-Security=max-age=31536000, SPRequestDuration=15, SPIisLatency=0,
#MicrosoftSharePointTeamServices=16.0.0.20308, X-Content-Type-Options=nosniff, X-MS-InvokeApp=1; RequireReadOnly,
#Content-Length=0, Content-Type=text/plain; charset=utf-8, Date=30 Feb 2012 20:08:25 GMT, P3P=CP="ALL IND DSP COR
#ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI", Server=Microsoft-IIS/10.0,
#X-Powered-By=ASP.NET'.
#At line:1 char:1
#+ Connect-SPOService -Url $sharePointUrl -Credential $credential
#+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#    + CategoryInfo          : NotSpecified: (:) [Connect-SPOService], NotSupportedException
#    + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService

Related posting:

PowerShell: Create Mailbox Report on Office 365

Leave a Reply

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