Specifications:
- It creates the log file afresh for every run
- Inserts two new lines after every folder ACLs output
- Uses Get-ACL
- Supports paths with spaces
Script:
$permsLogFile = "C:tempshare-permissions.txt" Write-Output "Start of the script" > $permsLogFile $networkPath = \<servername><sharename>" $subFolders = Get-ChildItem -Name $networkPath foreach ($Folder in $subFolders){ $cmd = ‘Get-Acl "’ + "$networkPath$Folder" + ‘"’ Write-Output "`r`n`r`nRunning Commamnd: $cmd" >> $permsLogFile Invoke-Expression $cmd | Write-Output >> $permsLogFile }
Output:
Start of the script
Running Commamnd: Get-Acl "\myserverusersFolder With Spaces"
Directory: \myserverusers
Path Owner Access
—- —– ——
Folder With Spaces BUILTINAdministrators NT AUTHORITYSYSTEM Allow FullControl…Running Commamnd: Get-Acl "\myserverusersTestUserg"
Directory: \myserverusers
Path Owner Access
—- —– ——
TestUserg NT AUTHORITYSYSTEM NT AUTHORITYSYSTEM Allow FullControl…
Requirement: Exporting Network Folder Permissions to Text with Powershell or VBS
Script:
$networkPath = "\<servername><sharename>" $permsLogFile = "C:tempshare-permissions.txt" $subFolders = Get-ChildItem $networkPath -Name foreach ($Folder in $subFolders){ $cmd = "cacls $networkPath$Folder" Write-Output "Running Commamnd: $cmd" >> $permsLogFile Invoke-Expression $cmd | Write-Output >> $permsLogFile }
Output:
Running Commamnd: cacls \myserverusersTestUserg \myserverusersTestUserg NT AUTHORITYSYSTEM:(OI)(CI)F BUILTINAdministrators:(OI)(CI)F myserverTestUserg:(OI)(CI)F Running Commamnd: cacls \myserverusersTestUserh \myserverusersTestUserh NT AUTHORITYSYSTEM:(OI)(CI)F BUILTINAdministrators:(OI)(CI)F myserverTestUserh:(OI)(CI)F