Posted On July 24, 2020

Quick Script to Test SharePoint Online Credentials

kimconnect 0 comments
blog.KimConnect.com >> Codes >> Quick Script to Test SharePoint Online Credentials
$principle = "[email protected]"  
$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 *

Related Post

PowerShell: Expand Volume of Virtual FileServer Role

Option 1: Expanding disk of a Virtual Machine in Hyper-V # ExpandVolumeVirtualFileServerRole.ps1 # Update these…

CSS Snippet to Target Phones, Tablets, and Desktops Separately

@media (min-width:20em) { /* iPhones, Androids portrait 480x320 phones */ } @media (min-width:30em) { /*…

PowerShell: Microsoft Clustered Disks Creation Script v 0.10

Code: <# Microsoft_Clustered_Disks_Creation_V0.10.ps1Purpose:This snippet streamlines the process of creating physical disk volumes on a Windows…