Copying a role from one vCenter to another

This is just the steps I did.  If you were going to do this a lot it could be put into a script/function.  Something like “Copy-VCRole -SourceVC xxx -TargetVC yyy -Role nameofrole“.  You also could kind of do source control by picking one vCenter to be the “role source server” and copy out the roles to the other vCenters from there.

  1. Connect to the vCenter that has the role you want.
  2. Save the privileges of the role you’re copying.
    1. $Role_OpsConsoleAccess = Get-VIPrivilege -Role “Ops Console Access”
  3. Connect to the vCenter you’re copying the role to.
  4. Create a new empty role.
    1. New-VIRole -Name “Ops Console Access”
  5. Add the privileges to the new role.
    1. $Role_OpsConsoleAccess | % { Set-VIRole -Role “Ops Console Access” -AddPrivilege (Get-VIPrivilege -PrivilegeItem $_.Name) }
  6. Check it.
    1. Get-VIRole “Ops Console Access” | select -expand privilegelist