Forum Discussion

Ameerm2023's avatar
Ameerm2023
Copper Contributor
Mar 30, 2023

Unattended scipts for connnect

For the MFA enabled account I need to run the PowerShell scripts without any user intersection (Unattended scripts) for the below connections

1.Connect-MsolService

2.Connect-SPOService

3.Connect-MicrosoftTeams

Please help to get the steps to connect.

  • The whole idea of having MFA enabled is for it to be interactive. For unattended scenarios, you should be running in the context of a service principal/application instead. Certificate-based authentication is supported for all M365 modules nowadays, sans the MSOnline one - you should be moving away from it and replace it with the Graph SDK for PowerShell.
    • Ameerm2023's avatar
      Ameerm2023
      Copper Contributor

      Thanks for your update!!.

       

      Will the certificate-based authentication support for all the 3 highlighted connections because we are having the script to get the details and based on that our reports are running but due to MFA Enabled the scripts are stopped. It will be more helpful if you share some documentation or steps to proceed further. VasilMichev 

      • VasilMichev's avatar
        VasilMichev
        MVP
        MSOnline does not support it, but as mentioned above you should be using the Graph SDK for PowerShell instead, which does support it.

Resources