Home > OS >  Powershell export three-layer directory folder permissions
Powershell export three-layer directory folder permissions

Time:11-23

Everyone a great god
I want to export server three-layer folder before a folder permissions, but the foreach will iterate over all subfolders, so will be very large,
About the third layer folder can exit the foreach


# using the Get - ChildItem need to look up permissions for file and folder
The Get - ChildItem 'C: \ Users \ LiM \ Documents \ Software' -recurse - Force | `
The ForEach - Object {
$I=$_
# use System. IO. The FileInfo. GetAccessControl (). The Access
The $_. GetAccessControl (). The Access | `

Select - Object @ {n="Path". E={$i.f ullname}}, @ {n="User"; E={$_. IdentityReference}}, `
@ {n="Permission"; E={$_. FileSystemRights}}, @ {n="Permission Type"; E={$_. AccessControlType}}, `
@ {n="IsInherited"; E={$_. IsInherited}}
} | `

Export to Csv C: \ Users \ LiM \ Documents \ user Csv - Encoding UTF8 - NoTypeInformation

CodePudding user response:

Use the foreach, the cycle is there other parameters
  • Related