Sharepoint Online Powershell命令ExecuteQuery未在服务器中运行 [英] Sharepoint Online Powershell command ExecuteQuery doesn't run in the server

查看:129
本文介绍了Sharepoint Online Powershell命令ExecuteQuery未在服务器中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,可以使用SharePoint Online租用的SharePoint PowerShell命令为所有Active Directory组更新自定义用户配置文件属性.

I have a script to update the custom User profile property for all Active directory groups using SharePoint PowerShell commands for the SharePoint Online tenancy.

查询无法在People Manager对象上执行getproperties方法,并且始终返回null.因此,ExceuteQuery方法也会失败.

The query fails to execute getproperties method on the People Manager object and always returns null. Because of this the ExceuteQuery method also fails.

查询在本地开发人员计算机上运行良好.

The query runs fine in the local developer machine.

请让我知道运行上述脚本的服务器计算机需要什么配置.服务器已经配置了最新的客户端SDK和SharePoint模块.

Please let me know what configuration is required in the server machine to run the above script. Server is already configured with latest client SDK and SharePoint modules.

下面的部分代码段:

 

$ ADGroup | span> {

Get-ADGroupMember$ADGroup|ForEach-Object{

          

           

= " i:0#.f | membership |" . "@ xxx.xxxxxxxxxxxxxxx.net"

$AccountName="i:0#.f|membership|"+$_."samAccountName"+"@xxx.xxxxxxxxxxxxxx.net"

  

   

= $ people GetPropertiesFor( )

$userprofile=$people.GetPropertiesFor($AccountName)

  

   

. Load( $ userprofile )

$context.Load($userprofile)

  

   

. ExecuteQuery()

$context.ExecuteQuery()

     

      

( $ userprofile . 电子邮件 -ne $ null )

If($userprofile.Email -ne$null)

      {

       {

      

       

. SetSingleValueProfileProperty( $ userprofile AccountName "Customprop" $ CustProp )

$people.SetSingleValueProfileProperty($userprofile.AccountName,"Customprop",$CustProp)

      

       

. ExecuteQuery()

$context.ExecuteQuery()

      

       

. 帐户名

$userprofile.AccountName

      } 

       } 

   } 

    } 

错误说明:

Exception calling "ExecuteQuery" with "0" argument(s): "The underlying connection was closed: An unexpected error occurred on a receive."

推荐答案

如果要在SharePoint Online中更新用户配置文件属性,请参考以下PowerShell脚本:

If you want to update the user profile properties in SharePoint Online, the following PowerShell script for your reference:

Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"  
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"  
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"  

#Mysite URL


site ='https://mysite-admin.sharepoint.com/'#这必须是"admin"地点. #Admin用户主体名称
site = 'https://mysite-admin.sharepoint.com/' # This needs to be the "admin" site. #Admin User Principal Name


admin ='lewis@mysite.onmicrosoft.com' #以安全字符串形式获取密码
admin = 'lewis@mysite.onmicrosoft.com' #Get Password as secure String


这篇关于Sharepoint Online Powershell命令ExecuteQuery未在服务器中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆