【发布时间】:2017-11-23 02:40:21
【问题描述】:
我正在尝试使用 CSOM 设置特定子站点的组所有者。
我的网站集路径是“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()
}
谁能解释我做错了什么?
【问题讨论】:
标签: powershell sharepoint office365 csom