Posted On March 29, 2019

Check Whether an Entity Has Access to a Directory or Its Children

kimconnect 0 comments
blog.KimConnect.com >> Codes , Windows >> Check Whether an Entity Has Access to a Directory or Its Children
Write-Host "This script just be ran in the context of a File Server Administrators member"
Write-Host "It only checks whether an account has explicit permissions to access to a directory and it's contents"

Do{
#$path=Read-Host -Prompt 'Enter a UNC path';
#$entity=Read-Host -Prompt 'Username or Groupname'
$path="\\FILESERVER01\SHARE01"
$entity="Everyone"
$directories=@{path=$path};
$exclusion

"Running as: "+(whoami)

    try{
        # Change into the filesystem's current location
        Push-Location (Get-Location -PSProvider FileSystem)
        @( $directories ) | ForEach-Object {
            $items=Get-ChildItem $_.path -recurse
            
            foreach ($item in $items){
                #$result+=,($item,(($item | get-acl).Access | ?{$_.IdentityReference -match $entity}).FileSystemRights)
                #Split-Path $item.pspath -Resolve -Leaf
                Convert-Path $item.pspath
                #Remove-NTFSAccess -Path (Convert-Path $item.pspath) -Account $entity -AccessRights FullControl -AccessType Allow
                #Remove-NTFSAccess -Path (Convert-Path $item.pspath) -Account $entity -AccessRights FullControl -AccessType Deny 
                }
            }
        }
    finally {
       # Revert to the previous location
       Pop-Location
       #$result
        }

$flag = Read-Host -Prompt 'Press Any Key = exit; R = Repeat...'} while ($flag -match '[Rr]')

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Hyper-V: Creating a New Virtual Machine

# Compulsory variables $hyperVHost='HYPERV007' $vmName='WindowsGoldenImage' $parentDirectory='C:\ClusterStorage\Volume5' $disk1Size='100GB' $memoryAllocation='8GB' $networkSwitch='PublicZone' $vlan='1005' $clusterName='DEV-CLUSTER05' # Optional variables $disk2Size=$false…

PowerShell Script to Read/Parse XML Files in a Directory

# This script is to be set on the FTP server or $folder = '\\FTPSERVER05\SFTP\EDI\INCOMING';$files…

Error: 502 Gateway Error

Explanation: 502 Gateway Error generally means connection problems with an upstream proxy. In this instance,…