Skip to content

Instantly share code, notes, and snippets.

@Trimad
Created May 14, 2022 21:20
Show Gist options
  • Save Trimad/9ca98d42ee39a28847f391d0b125a645 to your computer and use it in GitHub Desktop.
Save Trimad/9ca98d42ee39a28847f391d0b125a645 to your computer and use it in GitHub Desktop.
$Folder = "S:\path\to\folder"
$User = "Jane Doe"
$userPermissions = @()
$userPermissions += (Get-ADPrincipalGroupMembership $User).name
$folderPermissions = @()
$folderPermissions += (((Get-Acl $Folder).Access).IdentityReference).Value
$match = 0
foreach($i in $folderPermissions){
foreach($j in $userPermissions){
if($i.contains($j)){
$match = 1
Write-Output "$User is a member of the security group $j which grants the user access to $Folder"
}
}
}
if($match -eq 0){
Write-Output "$User does not have access to $Folder"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment