更新时间:2023-02-07 16:29:56
在这里
https://blog.areflyen.no/2017/06/18/problem-with-connecting-to-sharepoint-online-in-office-365-with-powershell-sharepoint-designer-and-other-3 -party-tools/
Does anyone know if it is possible to connect to SharePoint online via Client Side Object Model from PowerShell when Legacy Auth is disabled? When the legacy protocols are disabled I get this error trying to create a client context:
Failed to connect to (site), Exception calling "ExecuteQuery" with "0" argument(s): "Cannot contact web site (site) or the web site does not support SharePoint Online credentials. The response status code is 'Unauthorized'. The response
headers are 'X-SharePointHealthScore=0, X-MSDAVEXT_Error=917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+and+select+the+option+to+login+automatically.
Here's how I make the connection, which works fine with legacy authentication protocols enabled:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
$ccCtx = New-Object microsoft.sharepoint.client.clientcontext($Sitename)
$ccCtx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $Password)
$ccCtx.ExecuteQuery()
Here you go
https://blog.areflyen.no/2017/06/18/problem-with-connecting-to-sharepoint-online-in-office-365-with-powershell-sharepoint-designer-and-other-3-party-tools/