Link to home
Start Free TrialLog in
Avatar of creative555
creative555

asked on

Script to remove NTFS permissions from the shares

Hello,
I need a script that would read excel file with columns Path, IdentityReference, etc and would remove the NTFS permissions for the user/groups accounts that i specify in the excel file including all its subfolders and files.

For example, I have a great script that gets all the permissions into the excel file. Now I want to modify excel file and use similar script to remove all the permissions I list in the excel file.

Please help. THank you very much.


# Include only folders from the root path
Get-ChildItem "C:\installs" -Recurse | ?{ $_.PsIsContainer } | %{
  $Path = $_.FullName

  (Get-Acl $Path).Access | Select-Object `
    @{n='Path';e={ $Path }}, IdentityReference, AccessControlType, `
    InheritanceFlags, PropagationFlags, FileSystemRights, IsInherited
} | Export-CSV "Permissions.csv"
Avatar of Michael Fowler
Michael Fowler
Flag of Australia image

My not use VBA and do this directly from Excel. Here is an example of doing this which could be easily re-purposed for your needs

https://www.experts-exchange.com/questions/23178603/vba-to-add-permissions-to-shared-folder.html
Avatar of creative555
creative555

ASKER

oh. I will have to try that. Thank you very much!

I did vlookups once again and see that I did have those groups listed in the input files that I used. So, I was wrong. I think some children got permission propagated from the top and that's why I saw the groups that I didn't expect to see on some subfolders. So, there is a slight issue with propagation of permissions. At least I need to understand how this script propagates the permissions if they are applied on top. Could you please explain what this script does and how the propagation of permissions get applied.

THank you very much
ASKER CERTIFIED SOLUTION
Avatar of Michael Fowler
Michael Fowler
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello,
THank you so much for the response. It would be a lot easier to use powershell script that would read the input csv file and remove NTFS permissions that I listed from the specified folders.

Could you please suggest the powershell script that would do that. Thank you so much.