Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List Powershell连接到SharePointOnline_List_Powershell_Authentication_Sharepoint_Login - Fatal编程技术网

List Powershell连接到SharePointOnline

List Powershell连接到SharePointOnline,list,powershell,authentication,sharepoint,login,List,Powershell,Authentication,Sharepoint,Login,我开发了一个脚本,用于从SharePoint Online服务器检索列表项,该服务器在我的Windows 10笔记本电脑上运行良好,但在默认的Windows server 2012 R2实例上运行不正常。以下是相关代码: $context = New-Object Microsoft.SharePoint.Client.ClientContext($Url) $context.RequestTimeout = 360000 $context.Credentials = New-Object Mi

我开发了一个脚本,用于从SharePoint Online服务器检索列表项,该服务器在我的Windows 10笔记本电脑上运行良好,但在默认的Windows server 2012 R2实例上运行不正常。以下是相关代码:

$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$context.RequestTimeout = 360000
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
$list = $Context.Web.Lists.GetByTitle($ListTitle)
$qry = new-object Microsoft.SharePoint.Client.CamlQuery
$camlString = "somequery"
$qry.ViewXml = $camlString
$items = $list.GetItems($qry)
$Context.Load($items)
$Context.ExecuteQuery()
不幸的是,
$list
变量没有从2k12 R2服务器上的SharePoint获取任何列表,因此我最终得到以下错误

Exception calling "ExecuteQuery" with "0" argument(s): "Value cannot be null.
Parameter name: key"
At E:\temp\MDS_SharepointTracker_v2.ps1:131 char:5
+     $Context.ExecuteQuery()
+     ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException
我很确定这和身份验证有关,但我不知道是什么

两个系统上用于登录的凭据相同,两个系统都安装了SharePoint Online Management Shell,Powershell版本相同,并且加载了DLL(请参见下文)。两个系统上的代理设置相同。通过浏览器,我可以访问服务器上的SharePoint Online

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
唯一的区别是,我在笔记本上使用域用户登录(尽管不是来自与用于SP凭据的用户相同的域),而在服务器上,我使用的是本地用户


有人有什么想法或提示吗?

经过进一步调查,我终于找到了问题所在。 我测试脚本的服务器未加入域。因此,服务器和SP online之间不存在导致身份验证失败的信任关系,尽管没有该方向的任何指示。 检查
$error[0]| format list-force
是促使我测试身份验证问题的原因

已成功在其他不同客户端和加入域的服务器上尝试脚本

虽然不再需要,但我找不到在工作组服务器上运行脚本的方法,
SharePointOnlineCredentials
似乎无法在没有联盟的情况下处理登录…如果我错了,请更正我