我目前正在编写一个脚本,它连接到我们的SharePoint管理中心,并返回所有所有者(姓名和电子邮件)的所有网站的列表。
我尝试了PnP和SP的多种解决方案,但似乎都不起作用。
似乎我必须遍历所有站点,获取带有属性的web对象,获取权限级别,过滤它们以获得“完全控制”,然后查找具有这些权限的每个成员。但它并不是那样工作的?
还有没有人遇到过这个话题?
发布于 2021-06-01 10:44:41
这里有一个变通办法,可能会对你有所帮助。下面是一个导出.csv文件的脚本,其中包含每个网站集中具有完全控制角色的所有组。你可以使用列表来get all the group members,他们绝对有完全的控制权限。对于拥有完全控制权限的网站集管理员,只需使用Get-PnPSiteCollectionAdmin
$admin = "jerry@tenant.onmicrosoft.com";
$Credentials=Get-Credential
Connect-SPOService -Url https://tenant-admin.sharepoint.com -credential $Credentials
$Sites=Get-SPOSite
$OwnerList=@()
Foreach($Site in $Sites)
{
Write-Host $site.URL -ForegroundColor Cyan
#Get all Groups from the site permissions
$sitegroups = Get-SPOSiteGroup -Site $site.URL
#Get Group info and members that have site owners permissions
foreach ($sitegroup in $sitegroups)
{
foreach($role in $sitegroup.Roles)
{
try{
if ( $role.Contains(“Full Control”) )
{
$Row=""|Select SiteURL, FullControlGroupName;
$Row.SiteURL=$site.URL
$Row.FullControlGroupName=$sitegroup.title
$OwnerList+=$Row
}
}
catch{
write-host "$($_.Exception.Message)" -foregroundcolor red
}
}
}
}
$OwnerList | Export-Csv "C:\\OwnerList.csv" -NoTypeInformation https://stackoverflow.com/questions/67774481
复制相似问题