Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SharePoint Online CSOM/PowerShell权限_Powershell_Sharepoint_Permissions_Csom - Fatal编程技术网

SharePoint Online 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

我无法使用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.roleasignments
  • $app.BrowserFileHandling
  • $app.EffectiveBasePermissions
  • $app.Fields
  • $app.WorkflowAssociations
给我返回错误

集合尚未初始化。没有人要求或要求 请求尚未执行。它可能需要明确地定义 请求

例外

集合尚未初始化。没有人要求或要求 请求尚未执行。它可能需要明确地定义 请求

通常意味着尚未从服务器检索到您尝试使用的属性(例如HasuniQueryAssignments)

您可能需要额外的ExecuteQuery来加载每个应用程序

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()