Aug 02 2017 12:52 PM
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).
Is there a technique( or example) to use my identity/credentials after I have authenticated with Multifactor Authentication with Microsoft.SharePoint.Client.ClientContext?
Aug 02 2017 11:41 PM - edited Aug 02 2017 11:44 PM
SolutionConnecting 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 cmdlets at your disposal
https://github.com/SharePoint/PnP-PowerShell
Hope this helps!
Nov 16 2017 03:11 PM
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.
Jan 30 2018 07:44 AM - edited Jan 30 2018 11:57 PM
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
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
Jan 30 2018 03:03 PM
Feb 13 2018 10:27 AM
Seems to work with the app password now. Thanks for the nudge!
Mar 17 2020 04:41 AM
Worked great right up till the ability to create App Passwords disappeared from every O365 tenant I manage. Every client, even my companies own tenant, the option to create these is gone, and no one can seem to figure out how to re-enable it.
May 13 2020 12:06 AM
@clayosborn
Given you're using App Passwords, I hope it's safe to assume you're using entirely sharepoint online.
If that assumption is correct, you can make use of;
------------------EXAMPLE 9------------------
Connect-PnPOnline -Url https://contoso.sharepoint.de -AppId 344b8aab-389c-4e4a-8fa1-4c1ae2c0a60d -AppSecret a3f3faf33f3awf3a3sfs3f3ss3f4f4a3fawfas3ffsrrffssfd -AzureEnvironment Germany
Setting up Enterprise Applications within Azure AD is rather straight forward.
Aug 02 2017 11:41 PM - edited Aug 02 2017 11:44 PM
SolutionConnecting 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 cmdlets at your disposal
https://github.com/SharePoint/PnP-PowerShell
Hope this helps!