Avoid Credential Popup on Connect-SPOService

While using SharePoint online management shell, every time credential needs to be entered to connect to Tenant and is a hindrance for script execution.

There is a round about way to avoid this.

Below script can be used as a function / method inside the intended script:  (highlighted is the key line for making it feasible).

$adminUPN=”<login name for tenant / SharePoint admin.>”
$orgName=”<Name of the organization>”
$password = ConvertTo-SecureString “<Password>” -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ($adminUPN, $password)
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $Cred

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s