0

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
2
  • 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. Commented Mar 20, 2019 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
    Commented Mar 21, 2019 at 7:30

2 Answers 2

0

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

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

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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