11

I want to be able to update all users who have the Administrator checkbox selected without manually going through each of the user. In the same script I would like to add them to another Role. This way there is only one user with the Administrator checked.

I would like to use Sitecore PowerShell extensions module.

  • Updating answer to do help with roles now – Anicho Oct 10 '16 at 18:05
14

In SPE you should be able to do the following to get a list of all users with the admin role.

  1. This should get you users, with admin role who are not the default admin
    $users = Get-User -Filter* 
    | Where-Object {$_.IsAdministrator -and $_.Profile.UserName -ne 'sitecore\admin'}
  1. Then you should pipe through the $users variable add a new role and user set-user to remove admin writes by setting it to false
    $users | ForEachObject { 
                Add-RoleMember -Identity developer -Members $_.Profile.UserName 
                Set-User -Identity $_Profile.UserName -IsAdministrator $false }
  1. Complete script
    $users = Get-User -Filter* | Where-Object {$_.IsAdministrator -and $_.Profile.UserName -ne 'sitecore\admin'}

    $users | ForEachObject {Add-RoleMember -Identity developer -Members $_.Profile.UserName Set-User -Identity $_Profile.UserName -IsAdministrator $false }

Worth referring to SPE gitbook for User and Roles Commands and Set-User documentation for more info on what you can change with Set-User and how you can get different users.

| improve this answer | |
  • Would this get all the users who are checked as Administrator? – ASura Oct 10 '16 at 18:06
  • @ASURA updated answer this should, work as expected now – Anicho Oct 10 '16 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.