SharePoint Online CSOM/PowerShell权限
我无法使用CSOM/PowerShell列出权限 变量/过滤器SharePoint Online CSOM/PowerShell权限,powershell,sharepoint,permissions,csom,Powershell,Sharepoint,Permissions,Csom,我无法使用CSOM/PowerShell列出权限 变量/过滤器 $spSiteUrl = "https://mytenant.sharepoint.com" 获取凭证 if($cred -eq $null) { $cred = Get-Credential } 加载组件 [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null [System.Reflecti
$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.roleasignments
- $app.BrowserFileHandling
- $app.EffectiveBasePermissions
- $app.Fields
- $app.WorkflowAssociations
foreach($app in $apps){
if($app.Hidden -eq $false)
{
$ctx.Load($app)
$ctx.ExecuteQuery()
您最终会注意到,一些属性无法使用常规的csom api(如HasUniqueRoleAssignments)检索,对于那些属性,您可以使用Gary的powershell,这样您就有可能使用linq
foreach($app in $apps){
if($app.Hidden -eq $false)
{
$ctx.Load($app)
Load-CSOMProperties -object $app -propertyNames @("HasUniqueRoleAssignments")
$ctx.ExecuteQuery()