I recently had received a request to add several new Content Author accounts to the CMS and apply the exact user roles from a specific user to the new users. I ended up scripting this with Sitecore PowerShell Extensions using hardcoded variables (usernames and roles), but because I expect similar requests in the future, I wanted a quick way to copy roles from one user account to another to use in the future. Since I couldn't find a script readily available to do this, I developed my own.
The script utilizes the 'user' editor type (which doesn't happen to be listed on https://doc.sitecorepowershell.com/interfaces/interactive-dialogs - yet still works) within an interactive 'Show-ModalDialog.' It allows you to select a "source user" and a "target user" from the list of all available user accounts. After choosing both, the script iterates through each source user's roles and applies the target user to each user role.
The script loads the modal and requires the user to select a Source User and Target User. |
Clicking the ellipses button opens a separate dialog that lists all users. |
After selections are made, click OK to initiate the copying of roles. |
The script can be run in Sitecore PowerShell ISE or configured as a module that can be run from the Start Menu.
Happy scripting! 🦸♂️
0 comments:
Post a Comment