Skip to content

Instantly share code, notes, and snippets.

@dennythecoder
Last active January 3, 2020 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennythecoder/2db0e2120201ce721eaa5b669fd2e029 to your computer and use it in GitHub Desktop.
Save dennythecoder/2db0e2120201ce721eaa5b669fd2e029 to your computer and use it in GitHub Desktop.
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