mrbios Posted December 16, 2015 Posted December 16, 2015 (edited) I'm working on tidying up permissions using the NTFSSecurity module (This one: https://gallery.technet.microsoft.com/scriptcenter/1abd77a5-9c0b-4a2b-acef-90dbb2b84e85/view/Discussions/3) I've pre-planned all this so that every share and every permission is documented before i change it, I'm then using the documentation as a base for making this script. Having quite a lot of success with it so far, but the next step i want to use this powershell script is to remove all dead permissions. If a folder has a permission for a user that's been deleted showing up as S-1-5-21-.....etc. i want to remove those recursively starting with the top level folder. In theory so long as no one has been naughty by setting individuals on folders rather than groups there shouldn't be any to remove, but i've already found one... Anyone know how i can do that? I'm not sure if the NTFSSecurity module can do it because the remove and add ntfsaccess sections all require domain\userorgroup or localsecuritygroup\userorgroup...and i can't find anywhere stating if wildcards are allowed? I was hoping i could do something like: Remove-NTFSAccess -Path .\foldername -Account 'domain\s-1-5-21-*' but that would obviously be too easy, plus presumably once it's deleted it doesn't have a domain any more, and this module doesn't appear to work without something before the \. Any ideas? EDIT: Second question: Anyone know of any powershell modules that can control share permissions with the same simplicity that this NTFS Security module does? Edited December 16, 2015 by mrbios
Arthur Posted December 16, 2015 Posted December 16, 2015 Anyone know of any powershell modules that can control share permissions with the same simplicity that this NTFS Security module does? There's the Grant-SmbShareAccess and Revoke-SmbShareAccess cmdlets. They're included with WS2012 onwards. 1
mrbios Posted December 16, 2015 Author Posted December 16, 2015 You're like my digital angel lately Arthur! Answering all my problems Didn't realise those commands existed, my file server that the script will eventually run on is 2012R2 but my PC I'm playing around on and using for testing is only windows 7. I'll have to look into that, going to be a pain to test though, will have to setup another VM perhaps.
Steve21 Posted December 16, 2015 Posted December 16, 2015 https://gallery.technet.microsoft.com/scriptcenter/Remove-orphaned-unresolvabl-2ebca3eb Would that do it? Steve 2
mrbios Posted December 16, 2015 Author Posted December 16, 2015 Wohoo just the sort of thing i was after! Thank you both. These scripts are looking awesome now! With any luck these scripts will act as a backup to every share and ntfs permission i have set on every network folder on the network combined with the documentation i have, albeit that's only the second purpose of doing this, the primary purpose is mass cleanup and organisation! I could delete my file server virtual machine entirely, build a new one, run this script and be right back to where i was in the space of time it takes to build a VM + map the iSCSI stores. (you might be able to tell i don't do scripts often by the way i'm so impressed with myself lol )
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now