Last active
January 3, 2020 00:05
-
-
Save dennythecoder/2db0e2120201ce721eaa5b669fd2e029 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Create-SPPermissionsReport($path , $isRecursive) | |
{ | |
$web = (Get-SPWeb $path) | |
$users = (Get-SPUser -web $web -Limit ALL) | |
$users | ForEach { | |
[pscustomobject]@{ | |
'Name' = $_.Name | |
'Email' = $_.Email | |
'UserLogin' = $_.UserLogin | |
'Explicit Roles' = $_.Roles | ForEach { $_.Name } | |
'Roles via Groups' = $_.Groups | ForEach { $_.Roles | ForEach { $_.Name } } | |
'Groups' = $_.Groups | |
'Url' = $web.Url | |
} | |
} | |
if($isRecursive) | |
{ | |
$web.Webs | foreach{ | |
Create-SPPermissionsReport $_.Url $isRecursive | |
} | |
} | |
} | |
Create-SPPermissionsReport -Path "http://localhost" -IsRecursive $true | export-csv "C:\Temp\permissionsReport.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment