我想使用CSOM設置特定子站點的組所有者。使用Powershell和CSOM檢索Sharepoint聯機組
我的網站收藏路徑是「https://mytenant.sharepoint.com/」。
子站點路徑「https://mytenant.sharepoint.com/subsite」。
首先我要檢索我的特定子站點的SharePoint組,但我的代碼檢索我的收集站點的所有子站點組。
這裏是我的代碼:
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"
$siteURL = "https://mytenant.sharepoint.com/subsite"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$userId = "myID"
$pwd = Read-Host -Prompt "Enter password" -AsSecureString
$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userId, $pwd)
$ctx.credentials = $creds
$web = $ctx.web
$groups = $web.SiteGroups
$ctx.Load($groups)
$ctx.ExecuteQuery()
foreach($group in $groups){
Write-Host "Site Group : " $group.Title
$ctx.ExecuteQuery()
}
任何人都可以解釋我做錯了嗎?
我嘗試$ web.AssociatedVisitorGroup,仍然不起作用 – ysfibm
你是什麼意思?你得到錯誤,屬性爲空? – tinamou
它檢索我:Microsoft.SharePoint.Client.Group – ysfibm