使用Powershell将数据从Prem上的SQL Server添加到SharePoint列表

运行PowerShell脚本时出现错误。错误与缺少程序集有关。脚本将从SQL服务器获取数据,并在SharePoint列表中的每个项目中进行查询,并在有任何更改的情况下更新值。

我尝试在PowerShell代码中添加库,但出现相同的错误。

GAC    Version        Location
---    -------        --------
True   v4.0.30319     C:\WINDOWS\microsoft.Net\assembly\GAC_MSIL\microsoft.SharePoint.Client\v4.0_16.0.0.0__71e9bce111e9429c...
True   v4.0.30319     C:\WINDOWS\microsoft.Net\assembly\GAC_MSIL\microsoft.SharePoint.Client.Runtime\v4.0_16.0.0.0__71e9bce1...
Enter password: ************
5
Data Import Starts...
  

新对象:找不到类型[microsoft.SharePoint.SPQuery]:验证   包含此类型的程序集已加载。在C:\ SQL   Server \ SQLSharepointLoad.ps1:55 char:16   + $ SPQuery =新对象microsoft.SharePoint.SPQuery   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       + CategoryInfo:InvalidType:(:) [New-Object],PSArgumentException       + FullyQualifiedErrorId:TypeNotFound,microsoft.PowerShell.Commands.NewObjectCommand

     

在此对象上找不到属性“查询”。验证   属性存在并且可以设置。在C:\ SQL   Server \ SQLSharepointLoad.ps1:56 char:5   + $ SPQuery.Query =“

yangshegnhui 回答:使用Powershell将数据从Prem上的SQL Server添加到SharePoint列表

如果要从SQL Server获取数据,可以使用SQL Server PowerShell,请检查以下线程。

Using Powershell get Values from sql table

如果要从SharePoint获取数据,我建议您使用CSOM查询SharePoint列表数据(SPQuery是SSOM,可以在SharePoint服务器中运行)。

您可以从

获取CSOM SDK。

2013

https://www.microsoft.com/en-us/download/details.aspx?id=35585

2016

https://www.microsoft.com/en-us/download/details.aspx?id=51679

示例PowerShell以通过PowerShell与CSOM连接SharePoint。

https://social.technet.microsoft.com/Forums/office/en-US/e7894793-4d6f-4184-af2e-2ba685d6c90a/csom-powershell-and-sharepoint-2010-to-read-all-sites-subsites-libs-and-lists?forum=sharepointgeneralprevious

本文链接:https://www.f2er.com/3149667.html

大家都在问