Cloning share permissions from NTFS permissions on remote servers
As a system administrator, you may encounter situations where adding "Everyone" share permissions is not an option due to security settings. In these cases, you may need to clone the existing NTFS permissions to the share permissions in order to give the appropriate users access to the shared folder. In this blog post, we will discuss a script that automates this process for multiple remote servers.
The process involves looping through each server in the list, then looping through each shared folder on that server and outputting the server name, share name, and folder path.
The script then sets a list of forbidden folders, which are not allowed to have their NTFS permissions cloned to share permissions. If the folder path is not in the list of forbidden folders, the script continues to execute.
Next, the script defines a block of code (a script block) that will be executed on the remote server. This script block starts by getting the NTFS security descriptor for the folder and extracting the access control entries (ACEs) from the descriptor.
The ACEs are then looped through, and the corresponding share permission is granted for each ACE using the Grant-SmbShareAccess cmdlet. The script also handles converting the NTFS permission to the appropriate share permission by using a switch statement.
Finally, the script block is executed on the remote server using the Invoke-Command cmdlet, passing in the required arguments for $folderPath and $ShareName.
Overall, this script allows administrators to easily clone NTFS permissions to share permissions on multiple remote servers, saving time and effort compared to manually setting share permissions, Enjoy!
Comments
Post a Comment