Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Test-FolderAccess{
- [CmdletBinding()] Param(
- [Parameter(Mandatory=$True)]
- [string]$Path,
- [Parameter(Mandatory=$True)]
- [string]$SamAccountName
- )
- Import-Module ActiveDirectory
- (Get-ACL $folder).Access | ForEach-Object{
- $member = $null
- if( $_.IdentityReference -Like "$env:USERDOMAIN\*" ){
- try{ $member = Get-ADGroupMember ($_.IdentityReference -replace "$env:USERDOMAIN\\","") -Recursive }catch{}
- }
- $output = [PSCustomObject]@{
- IdentityReference = $_.IdentityReference;
- IsMemberOfTheADGroup = $member.SamAccountName -contains $SamAccountName
- FileSystemRights = $_.FileSystemRights;
- AccessControlType = $_.AccessControlType;
- IsInherited = $_.IsInherited;
- InheritanceFlags = $_.InheritanceFlags;
- PropagationFlags = $_.PropagationFlags;
- }
- Write-Output $output
- }
- }
- Test-FolderAccess "\\SERVER\SHARE" "USERNAME" | FT -AutoSize
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement