We help IT Professionals succeed at work.

script to export ntfs permisison to csv file

131 Views
2 Endorsements
Last Modified: 2019-03-07
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
Comment
Watch Question

Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
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?

Author

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

Author

Commented:
any help plz?
Lionel MMSmall Business IT Consultant
CERTIFIED EXPERT

Commented:
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

Author

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

Author

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 Administrator
CERTIFIED EXPERT

Commented:
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)
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Lionel MMSmall Business IT Consultant
CERTIFIED EXPERT

Commented:
well done and on your own--good job
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.