[英]Adding data from SQL server on Prem to SharePoint List using Powershell
I am getting an error when running the PowerShell script.运行 PowerShell 脚本时出现错误。 Error is related to a missing assembly.
错误与缺少的程序集有关。 Script will get the data from the SQL server and query through each item in the SharePoint list and update the values if any changes.
脚本将从 SQL 服务器获取数据,并通过 SharePoint 列表中的每个项目进行查询,如果有任何更改,则更新值。
I tried adding libraries in the PowerShell code but I am getting the same error.我尝试在 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...
New-Object: Cannot find type [Microsoft.SharePoint.SPQuery]: verify that the assembly containing this type is loaded.
新对象:找不到类型 [Microsoft.SharePoint.SPQuery]:验证是否已加载包含此类型的程序集。 At C:\SQL Server\SQLSharepointLoad.ps1:55 char:16 + $SPQuery = New-Object Microsoft.SharePoint.SPQuery + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: InvalidType: (:) [New-Object], PSArgumentException + FullyQualifiedErrorId: TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
在 C:\SQL Server\SQLSharepointLoad.ps1:55 char:16 + $SPQuery = 新对象 Microsoft.SharePoint.SPQuery + ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ + CategoryInfo: InvalidType: (:) [New-Object], PSArgumentException + FullyQualifiedErrorId: TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
The property 'Query' cannot be found on this object.
在此 object 上找不到属性“查询”。 Verify that the property exists and can be set.
验证该属性是否存在并且可以设置。 At C:\SQL Server\SQLSharepointLoad.ps1:56 char:5 + $SPQuery.Query = "
在 C:\SQL Server\SQLSharepointLoad.ps1:56 char:5 + $SPQuery.Query = "
If you want to get data from SQL Server, you could use SQL Server PowerShell, check below thread.如果你想从 SQL 服务器获取数据,你可以使用 SQL 服务器 PowerShell,检查下面的线程。
Using Powershell get Values from sql table 使用 Powershell 从 sql 表中获取值
If you want to get data from SharePoint, I do suggest you use CSOM to query SharePoint list data(SPQuery is SSOM which can be run in SharePoint server).如果你想从 SharePoint 获取数据,我建议你使用 CSOM 来查询 SharePoint 列表数据(SPQuery 是 SSOM,可以在 Z97F02F6993B93732B0D39DFE004699 服务器上运行)。
You could get CSOM SDK from您可以从
2013 2013
https://www.microsoft.com/en-us/download/details.aspx?id=35585 https://www.microsoft.com/en-us/download/details.aspx?id=35585
2016 2016 年
https://www.microsoft.com/en-us/download/details.aspx?id=51679 https://www.microsoft.com/en-us/download/details.aspx?id=51679
Sample PowerShell to connect SharePoint by PowerShell with CSOM.样品 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://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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.