I inherited a SharePoint Online old UI env and the client would to get a overview off all current security settings. I've found multiple tools (SysKit, Tru Sp auditor, ...) who will do almost what I need. But I doesn't give me a simple, transparant overview, level site/subsite.
I tried some scripting like ...
#Import the required client dlls
Import-Module 'C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.dll'
Import-Module 'C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client.Runtime\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.Runtime.dll'
#Generic method to load the properties
Function Invoke-LoadMethod() {
param(
[Microsoft.SharePoint.Client.ClientObject]$Object = $(throw "Please provide a Client Object"),
[string]$PropertyName
)
$ctx = $Object.Context
$load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load")
$type = $Object.GetType()
$clientLoad = $load.MakeGenericMethod($type)
$Parameter = [System.Linq.Expressions.Expression]::Parameter(($type), $type.Name)
$Expression = [System.Linq.Expressions.Expression]::Lambda(
[System.Linq.Expressions.Expression]::Convert(
[System.Linq.Expressions.Expression]::PropertyOrField($Parameter,$PropertyName),
[System.Object]
),
$($Parameter)
)
$ExpressionArray = [System.Array]::CreateInstance($Expression.GetType(), 1)
$ExpressionArray.SetValue($Expression, 0)
$clientLoad.Invoke($ctx,@($Object,$ExpressionArray))
}
#Mysite URL
$site = 'https://tenant.sharepoint.com/'
#Admin User Principal Name
$admin = '[email protected]'
#Get Password as secure String
$password = Read-Host 'Supersecret Password' -AsSecureString
#Get the Client Context and Bind the Site Collection
$context = New-Object Microsoft.SharePoint.Client.ClientContext($site)
#Authenticate
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($admin , $password)
$context.Credentials = $credentials
$list = $context.Web.Lists.GetByTitle('D1')
$context.Load($list)
Invoke-LoadMethod -Object $list -PropertyName "HasUniqueRoleAssignments"
$context.ExecuteQuery()
Write-Host $list.HasUniqueRoleAssignments
All of them are getting an error on the commando
$list = $context.Web.Lists.GetByTitle('D1')
Any ideas out here?
edit: error
Exception calling "ExecuteQuery" with "0" argument(s): "List 'D1' does not exist at site with URL 'https://tenant.sharepoint.com/'."
At line:7 char:2
+ $context.ExecuteQuery()
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ServerException