script to export ntfs permisison to csv file

hello

i need a script to export ntfs right on user redirection folder, its a folder in windos 2012 server where every user have his redirected folder like this:

redirected_folder
john.smith
antonio.banderas
....

i need a script to export ntfs right for all this folder

thanks for help
cawasakiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve KnightIT ConsultancyCommented:
Is this to audit what is there or in order to set permissions again at new location?  Also do you just want to know permissions on the root of each sub directory or to iterate down under that as any file or sub folder could have different permissions?
cawasakiAuthor Commented:
hello,

its for audit actual permission, actually i need only the root pemrission on every folder, the goal is to be sure tha every use folder i have full control right of the user on the folder and subfolder and files right.

after that i will need a script to apply this right on every folder by getting the user name from the folder like this:

fodlername:
john.smith
isabella.Torro

so for folder john.smith check if user john.smith have full control, if not apply the  full control ntfs permission to folder subfolder and files.
same think for isabella.torro folder...

thanks for help
cawasakiAuthor Commented:
any help plz?
Get a highly available system for cyber protection

The Acronis SDI Appliance is a new plug-n-play solution with pre-configured Acronis Software-Defined Infrastructure software that gives service providers and enterprises ready access to a fault-tolerant system, which combines universal storage and high-performance virtualization.

Lionel MMSmall Business IT ConsultantCommented:
just to get the NTFS permissions simply add this to any script or create a new one using

icacls \\servername\sharename\*. /T /C >C:\Logs\NTFS.Log
or
icacls e:\redirected_folders\*. /T /C >C:\Logs\NTFS.Log
make sure you use the *. or else you will get persmissions on all the files too
cawasakiAuthor Commented:
hello Lionel,

ok how i can only have the ntfs permission of all folder without subfolder and have this on csv file.

also how i can see the ntfs permission or understand the log file, because i dont see what permission is:

NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
                             CREATOR OWNER:(I)(OI)(CI)(IO)(F)

thnaks for help
cawasakiAuthor Commented:
i have found what i need:

$FolderPath = Get-ChildItem -Directory -Path "c:\temp" -Force
$Output = @()
ForEach ($Folder in $FolderPath) {
    $Acl = Get-Acl -Path $Folder.FullName
    ForEach ($Access in $Acl.Access) {
$Properties = [ordered]@{'Folder Name'=$Folder.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Output += New-Object -TypeName PSObject -Property $Properties            
}
}
$Output | Out-GridView

Open in new window


now i will create other question for script to add ntfs permission
Jeff GloverSr. Systems AdministratorCommented:
First line (NT Authority\System)
(I) = Inherited from Parent container, (OI)(CI) = Object Inherit, Container Inherit  (F)= Full Access
Second line (Creator Owner)
(I) = Inherited, (OI)(CI)(IO) = Object Inherit, Container Inherit, Applied only to subfolders and files, (F) = Full Access

If you want more information see this article
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc753525(v=ws.10)
cawasakiAuthor Commented:
$FolderPath = Get-ChildItem -Directory -Path "c:\temp" -Force
$Output = @()
ForEach ($Folder in $FolderPath) {
    $Acl = Get-Acl -Path $Folder.FullName
    ForEach ($Access in $Acl.Access) {
$Properties = [ordered]@{'Folder Name'=$Folder.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Output += New-Object -TypeName PSObject -Property $Properties            
}
}
$Output | Out-GridView

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lionel MMSmall Business IT ConsultantCommented:
well done and on your own--good job
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.