powershell - Change ACL permissions out -
powershell - Change ACL permissions out -
is possible alter permissions output file context from:
account folder path identityreference accesscontroltype isinherited inheritanceflags propagationflags nt authority\system allowfalsecontainerinherit objectinheritnone \uklonfap11\data\apps\access2 nt authority\system allow false containerinherit objectinherit none builtin\administrators allowfalsecontainerinherit objectinheritnone \uklonfap11\data\apps\access2 builtin\administrators allow false containerinherit objectinherit none
to like:
account ace string object path scheme allow total control, folder, subfolders , files (inherited) \ukshefap08\e$\data\global\phe test cases\back of phe\test cases\benefit statements allow modify, folder, subfolders , files (inherited) \ukshefap08\e$\data\global\phe test cases\back of phe\test cases\benefit statements
does create sense or requires finish alter code: snippet of code is:
$outfile = "c:\users\munjanga\documents\aon project\execute\output.csv" $header = "folder path,identityreference,accesscontroltype,isinherited,inheritanceflags,propagationflags" del $outfile add-content -value $header -path $outfile $rootpath = "c:\users\munjanga\documents\operations orchestration" $folders = dir $rootpath -recurse | {$_.psiscontainer -eq $true} $isinherited = @{ $true = 'inherited' $false = 'not inherited' } $inheritance = @{ 0 = 'files only' 1 = 'this folder , subfolders' 2 = 'this folder , files' 3 = 'subfolders , files' } $fldr = $folder.fullname $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}}}
you utilize calculated properties this:
$fldr = $folder.fullname get-acl $fldr | select -expand access | select @{n='account';e={$_.identityreference}}, @{n='ace string';e={"{0} {1}, {2} ({3})" -f $_.accesscontroltype, $_.filesystemrights, $_.inheritanceflags, $_.isinherited}}, @{n='object path';e={$fldr}}
custom text can provided via hashtables, e.g.:
$isinherited = @{ $true = 'inherited' $false = 'not inherited' } $inheritance = @{ 0 = 'files only' 1 = 'this folder , subfolders' 2 = 'this folder , files' 3 = 'subfolders , files' } $fldr = $folder.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.value__], $isinherited[$_.isinherited]}}, @{n='object path';e={$fldr}}
however, permissions displayed in gui consist of more single ace, there no simple way accomplish want. you'd have evaluate aces of given acl , merge ones matching particular criteria single display record.
as side note: shouldn't hand-craft csvs. allow powershell work you:
$folders | % { $fldr = $_.fullname get-acl $fldr | select -expand access | ... } | export-csv $outfile -notype
powershell
Comments
Post a Comment