有網上如何訪問/使用SharePoint客戶端對象模型PowerShell的例子很多。但是,當然,他們似乎不適合我。我似乎無法訪問某些憑據代碼:使用SharePoint CSOM使用PowerShell
PS C:\Scripts> $webUrl = "https://abc.sharepoint.com>"
PS C:\Scripts> $username = "user3"
PS C:\Scripts> $password = "password"
PS C:\Scripts>
PS C:\Scripts> $ctx = new-object Microsoft.SharePoint.Client.ClientContext($webUrl)
PS C:\Scripts> $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
New-Object : Cannot find type Microsoft.SharePoint.Client.SharePointOnlineCredentials]: make sure the assembly containing this type is loaded.
At line:1 char:30
+ $ctx.Credentials = New-Object <<<< Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
我試圖訪問我們維護的SharePoint 2010服務器,它需要登錄身份驗證。有誰知道我做錯了什麼?
OK,這麼多的反應告訴我,我使用此連接不正確的資格認證類型。所以我改成:
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$clientContext.AuthenticationMode = "FormsAuthentication"
$clientContext.FormsAuthenticationLoginInfo = New-Object Microsoft.SharePoint.Client.FormsAuthenticationLoginInfo("myDomain\myUser", "myPassword")
這似乎工作正常。但後來......
$web = $clientContext.Web
$properties = $web.AllProperties
$clientContext.Load($web)
給我:
> Cannot find an overload for "Load" and the argument count: "1". At
> line:1 char:20
> + $clientContext.Load <<<< ($web)
> + CategoryInfo : NotSpecified: (:) [], MethodException
> + FullyQualifiedErrorId : MethodCountCouldNotFindBest
,當我嘗試看看$ clientContent對象:
PS C:\Scripts> $clientContent | get-member
Get-Member : No object has been specified to the get-member cmdlet.
At line:1 char:28
+ $clientContent | get-member <<<<
+ CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
+ FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
這是沒有意義的。任何人有任何幫助?
謝謝大家。儘管我們使用表單/聲明身份驗證,但我嘗試了所有這些方法,但仍然沒有工作。無論我嘗試什麼,這都是我得到的: PS C:\ Scripts> $ clientContext。負載($ web) 找不到「負載」過載和參數計數:「1」。 在行:1個字符:20 + $ clientContext.Load <<<<($網) + CategoryInfo:NotSpecified:(:) [],MethodException + FullyQualifiedErrorId:MethodCountCouldNotFindBest –