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() {
    [Microsoft.SharePoint.Client.ClientObject]$Object = $(throw "Please provide a Client Object"),
    $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(
    $ExpressionArray = [System.Array]::CreateInstance($Expression.GetType(), 1)
    $ExpressionArray.SetValue($Expression, 0)

 #Mysite URL
 $site = 'https://tenant.sharepoint.com/'

 #Admin User Principal Name
 $admin = 'admin@tenant.onmicrosoft.com'

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

 $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($admin , $password)
 $context.Credentials = $credentials

 $list = $context.Web.Lists.GetByTitle('D1')

 Invoke-LoadMethod -Object $list -PropertyName "HasUniqueRoleAssignments"


 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
  • The error message could not be much clearer: your code expects a list with the title "D1" to exist on the site but fails to one. – Robert Lindgren Mar 20 '19 at 19:01
  • I tried all kinds of listnames (D1, Documents, Documenten, Gedeelde documenten (native lang)) but all of them returned the same error. 'List does not exsist' – Emiel Mar 21 '19 at 7:30

You could use the following scripts to check all the lists title:

$lists = $context.web.Lists
foreach($list in $lists){
    Write-host $list.title}

Then try one of the titles to see if this issue still exists.

| improve this answer | |

ShareGate comes with a number of good reports out of the box, and you can get a 14 days trial version. One of the best reports is that permissions overview

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.