Got a task to check permissions on a folder, that is static, across all the servers in my environment, I need to check the folder if Local Users group is added to the folder, and if not add is as read/write not full control. Is there anyway to powershell this action?
My own script I only got half way there with just checking the folder in question on a list of servers but it comes back with all perms as its not just looking for Users group, and I dont know how to add in a IF switch to then add it to the server is it isnt there, or have the first line generate a list of servers that are missing the User group, and then take that group and run a second half of the script to add the group. Im sure my way below is primitive so it doesnt need to build off this if there is a more efficient way.
$Servers = Get-Content "C:Servers.txt" Invoke-Command -Computername $Servers -scriptblock { get-acl c:foldername | select -expand access } | export-csv c:perms.csv
submitted by /u/techguy404
[link] [comments]
The post Powershell add user group perms to folders appeared first on How to Code .NET.