Forum Discussion

Chris Stewart's avatar
Chris Stewart
Brass Contributor
Aug 02, 2017
Solved

Using SharePoint Client Side Object Model with PowerShell and Multifactor Authentication

There is a technique to connect to SharePoint Online with PowerShell when Multi-factor Authentication(MFA) is enabled.

https://technet.microsoft.com/en-us/library/fp161372.aspx

 

There is a very limited list of SharePoint Online cmdlets
https://technet.microsoft.com/en-us/library/fp161364.aspx

 

I would like to leverage the client side object model to access objects like the webs(spweb) and lists(splist).

https://dev.office.com/sharepoint/docs/sp-add-ins/complete-basic-operations-using-sharepoint-client-library-code

 

Is there a technique( or example) to use my identity/credentials after I have authenticated with Multifactor Authentication with Microsoft.SharePoint.Client.ClientContext?


  • Connecting to SharePoint Online using PnP PowerShell Connect-PnPOnline allows you to specify a UseWebLogin parameter. This allows you to connect with MFA enabled. Once connected you'd have many more https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/readme.mdat your disposal

     

    https://github.com/SharePoint/PnP-PowerShell

     

    Hope this helps!

7 Replies

  • paulpascha's avatar
    paulpascha
    Bronze Contributor

    Connecting to SharePoint Online using PnP PowerShell Connect-PnPOnline allows you to specify a UseWebLogin parameter. This allows you to connect with MFA enabled. Once connected you'd have many more https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/readme.mdat your disposal

     

    https://github.com/SharePoint/PnP-PowerShell

     

    Hope this helps!

    • Henry Ong's avatar
      Henry Ong
      Copper Contributor

      Would there happen to be a way to do this without the web login? Use case: automated PowerShell scripts running on a schedule where the service account also has MFA enabled. 

      • Christophe Heureux's avatar
        Christophe Heureux
        Copper Contributor

        i was able to run my azure automation script that accesses an SPO tenant with CSOM + an account that has MFA authentication enabled by using the app password

        https://support.office.com/en-us/article/create-an-app-password-for-office-365-3e7c860f-bda4-4441-a618-b53953ee1183

        i deleted the default app pass that was created, as it didn't seem to work in powershell, i found another post on tech community that describes the same problem

        https://support.office.com/en-us/article/create-an-app-password-for-office-365-3e7c860f-bda4-4441-a618-b53953ee1183

Resources