Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This will enumerate all the permissions for the current folder and write them into an output file based on the machine
- # name, date, time at the $destPath location.
- # User tunable, set this to where you want the output to go if it's different than the current folder:
- $destPath="c:\users\jimbo\Documents\"
- # Get hostname
- $hostname = $env:COMPUTERNAME
- # Try to get the domain name, fallback to just hostname if domain can't be retrieved
- try {
- $domain = ([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).Name
- $filenamePrefix = "$domain-$hostname"
- } catch {
- $filenamePrefix = $hostname
- }
- # Get current date and time
- $now = Get-Date
- $formattedDateTime = $now.ToString("yyMMdd-HHmm")
- # Construct the filename
- $outputFileName = "$destPath$filenamePrefix-$formattedDateTime.csv"
- Get-ChildItem | ForEach-Object {
- $acl = Get-Acl $_.FullName
- [PSCustomObject]@{
- Path = $_.FullName
- Owner = $acl.Owner
- Access = ($acl.Access | ForEach-Object { "$($_.IdentityReference) - $($_.FileSystemRights)" }) -join "; "
- }
- } | Export-Csv -Path $outputFileName -NoTypeInformation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement