Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

ACL output CSV file to display security permissions include _"Allow Full Control, this folder, subfolders and files (Inherited)"

$
0
0

I have my Powershell script that displays security ACL permissions and outputs to a file. At the moment my output is only displaying "Allowed Inheritance" but i want it to display like this "SYSTEMAllow  Full Control, this folder, subfolders and files (Inherited)" to include the folder, subfolder, files text. The code is below:

	$OutFile = "C:\Users\munjanga\Documents\AoN Project\Execute\$([Environment]::MachineName).txt"	
	$Header = "Account,Ace String,Object Path"
	Del $OutFile
	Add-Content -Value $Header -Path $OutFile 

	$RootPath = "C:\Users\munjanga\Documents\Operations Orchestration"

	$Folders = dir $RootPath -recurse | where {$_.psiscontainer -eq $true}

	$isInherited = @{
 	 $true  = 'Inherited'
 	 $false = 'Not Inherited'
	}

	$inheritance = @{
 	 0 = 'files only'
 	 1 = 'this folder and subfolders'
 	 2 = 'this folder and files'
 	3 = 'subfolders and files'
	}

	$fldr = $Folder.FullName

$Folders | % {
 	$Folders | % {
 	$fldr = $_.FullName
	Get-Acl $fldr | select -Expand Access |
 	 select @{n='Account';e={$_.IdentityReference}},
         @{n='Ace String';e={"{0} {1}, {2} ({3})" -f $_.AccessControlType,
           $_.FileSystemRights, $inheritance[$_.InheritanceFlags],
           $isInherited[$_.IsInherited]}},
        @{n='Object Path';e={$fldr}} | ConvertTo-Csv -NoTypeInformation | Select -Skip 1 | % {$_ -replace '"', ""} | Out-File $OutFile -Force -Encoding ascii -Append}}


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>