top of page

PowerShell | Share Permission Audit

Name: Windows Share Access Tester
Description: Goes to a parent network share and tests access to subfolders.
Purpose: Find shares that are not locked down and all Domain Users have Access to.
Create a user account on the Domain that is only member of Domain Users.
Log in with the user account and run script against parent file Share.
The script pulls a list of Sub-Dir and then tries to access each sub-dir.
If the user account can access sub-dir it is exported to txt file.

# UNC Parent File Share Path
$PathtoCheck = "\\Servername\ParentShare"
# Goes down one level and grabs subdirectories
$DirList=Get-ChildItem $PathtoCheck -Directory | Select -ExpandProperty Name
# Da Loop
Foreach($Path in $DirList){
#Null Variable
#Test Access to Sub-Dir
$Child=Get-ChildItem "$PathtoCheck\$Path" -Directory -ErrorAction Continue | Select -ExpandProperty Name
#If Dir Inaccessible 
If($Child -eq $NULL){
Write-Host "Access OK"

#If Dir Was Accessible
"$PathtoCheck\$Path `t Directory Accessible" | Tee-Object C:\temp\Dir-Check6.txt -Append

bottom of page