1

我一直在尝试将程序集加载到 powershell 以获取共享点,并且它们中的大多数都可以正常工作,如下所示:

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

但是当我尝试添加具有不同文件路径的文件时:

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\ClientBin\Microsoft.SharePoint.Client.Silverlight.dll"

我收到以下错误:

“Add-Type : 无法加载一种或多种请求的类型。检索 LoaderExceptions 属性以获取更多信息。”

有人能帮忙吗?

- - -更新 - - -

    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
   #Bind to site collection
   $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
   $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
   $Context.Credentials = $Creds

   #Retrieve list
   $List = $Context.Web.Lists.GetByTitle($DocLibName)
   $Context.Load($List)
   $Context.ExecuteQuery()

    $SPFolder = New-Object Microsoft.SharePoint.Client.Folder
4

1 回答 1

0

是在多个程序集中Microsoft.SgarePoint.Client.Folder定义的,每个支持这个的平台都有一个。鉴于 powershell 在 Desktop CLR 上运行,您只需要加载程序集的桌面版本:

Microsoft.SharePoint.Client.Silverlight(在 Microsoft.SharePoint.Client.Silverlight.dll 中);

Microsoft.SharePoint.Client.Phone(在 Microsoft.SharePoint.Client.Phone.dll 中)

Microsoft.SharePoint.Client(在 Microsoft.SharePoint.Client.dll 中)

您需要传入正确的构造函数参数:

 public Folder(
    ClientRuntimeContext context,
    ObjectPath objectPath
 )

但我想改用下面的方法( GetFolderByServerRelativeUrl)会更容易。

于 2014-07-23T10:44:04.613 回答