我有问题使用CSOM/PowerShell列出权限列表。SharePoint Online CSOM/PowerShell权限
变量/过滤器
$spSiteUrl = "https://mytenant.sharepoint.com"
获取证书
if($cred -eq $null)
{
$cred = Get-Credential
}
装载程序集
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null
连接到SharePoint,并显示网站标题
Write-Host "Connecting to SharePoint"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($spSiteUrl)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.UserName, $cred.Password)
$web = $ctx.Web
$ctx.Load($web)
$ctx.ExecuteQuery()
Write-host "Site Name : $($web.Title)"
功能列表 “有用” 的应用
function getApps($web)
{
$appsArray = @()
$apps = $web.Lists
$ctx.Load($apps)
$ctx.ExecuteQuery()
Write-Host "List of aplications : "
foreach($app in $apps){
if($app.Hidden -eq $false)
{
$item = New-Object PSObject
$item | Add-Member -MemberType NoteProperty -Name 'Col1' -Value $($app.Title)
$item | Add-Member -MemberType NoteProperty -Name 'Col2' -Value $($app.HasUniqueRoleAssignments)
$item | Add-Member -MemberType NoteProperty -Name 'Col3' -Value $($app.RoleAssignments)
$item | Add-Member -MemberType NoteProperty -Name 'Col4' -Value $($app.BrowserFileHandling)
$item | Add-Member -MemberType NoteProperty -Name 'Col5' -Value $($app.EffectiveBasePermissions)
$item | Add-Member -MemberType NoteProperty -Name 'Col6' -Value $($app.Fields)
$item | Add-Member -MemberType NoteProperty -Name 'Col7' -Value $($app.WorkflowAssociations)
$appsArray += $item
}
}
$appsArray | Format-Table
}
调用函数
getApps($web)
我的问题是:
- $ app.HasUniqueRoleAssignments
- $ app.RoleAssignments
- 个$ app.BrowserFileHandling
- $ app.EffectiveBasePermissions
- $ app.Fields
- $ app.WorkflowAssociations
回到我的错误
收集尚未初始化。它没有被请求或者 请求没有被执行。这可能需要明确 要求..