Authenticate Connect-SPOService without user interaction

Garima Das 1,041 Reputation points
2021-07-30T11:05:58.777+00:00

Hi Experts,

I am using Connect-SPOService to connect to the SharePoint admin site and then making setting changes to it. I have created a script for this purpose and we are intending to run the script using a pipeline in DevOps. But in the whole process, providing the credentials while the script runs is a blocker.

How can we pass credentials to the Connect-SPOService without user interaction?

Thanks.

Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

3 answers

Sort by: Newest
  1. Salamat Shah 990 Reputation points MVP
    2026-11-15T08:16:40.2166667+00:00

    Dear Das,

    Yes, you can automate Connect-SPOService without interactive user sign-in, but storing usernames/passwords in scripts is not recommended.

    The Microsoft-supported approach for non-interactive SharePoint Online administration is app-based authentication (service principal + certificate) rather than passing user credentials to Connect-SPOService. This is more secure, compliant, and suitable for Azure DevOps pipelines.

    Recommendations:

    • Use Microsoft Entra ID (Azure AD) App Registration with certificate-based authentication.
    • Store the certificate securely (Azure Key Vault, secure certificate store).
    • Run the script from Azure DevOps Service Connection, Managed Identity, or a service principal.

    Was this answer helpful?

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    2 deleted comments

    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.