Please enable Javascript for better experience...
 
Migrate Roles & Permissions from one vCenter to another vCenter
By Pranay Jha | Jan 12, 2017 | In Tips | Total Views [ 807 ]
Taged In
(2 Like)
Rate

During one of the activity we performed in our orgnaziation to rebuild Virtual Center, we faced issue that few of the admins were reporting access issue. It was because if we rebuild virtual center, it didn't add existing Roles and Permissions in Virtual Center. Hence I planned to export roles from one vcenter to this newly rebuilt vcenter. However creating manual roles and adding to permission take longer if we have large number of users listed in ACL. Hence performed automation through below script to reduce manual efforts. It worked perfectly and save few hours.


# Variables
$VC1="vCenter1"
$VC2="vCenter2"
 
# Set the PowerCLI Configuration to connect to multiple vCenters
Set-PowerCLIConfiguration -DefaultVIServerMode multiple -Confirm:$false
 
# Connect to both the source and destination vCenters
connect-viserver -server $VC1, $VC2
 
# Get roles to transfer
$roles = get-virole -server $VC1
 
# Get role Privileges
foreach ($role in $roles) {
[string[]]$privsforRoleAfromVC1=Get-VIPrivilege -Role (Get-VIRole -Name $role -server $VC1) |%{$_.id}
 
# Create new role in VC2
New-VIRole -name $role -Server $VC2
 
# Add Privileges to new role.
Set-VIRole -role (get-virole -Name $role -Server $VC2) -AddPrivilege (get-viprivilege -id $privsforRoleAfromVC1 -server $VC2)
}
 
disconnect-viserver –server $VC1, $VC2


Thanks for visiting here. Share this article if you found it useful.
Join Facebook Group https://www.facebook.com/groups/VMwareInsight/
Like Facebook Page https://www.facebook.com/VMwareInsight/
Connect to twitter https://twitter.com/VMwareInsight
Share this on Social Media

About the Author

Pranay Jha
Pranay Jha
Founder, Contributer VMwareInsight.com
Follow me

facebook linkedin twitter G+ VMTN

My name is Pranay Jha, working in IBM as Technical Solution Architect for Virtualization platform. I have been working in IT for near around 10 years. Passionate to get involved as an Independent blogger for my blog http://vmwareinsight.com. I am VMware vExpert 2016/2017, VCAP5-DCD/DCA, VCP5-DCV, VCA-Cloud, VCE-CIA, MCSE, MCITP, MCSA(Messaging). For any query or suggestion, please connect me at pranay1988jha@gmail.com. Thanks for visiting here.

 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment
 
Sponsors
 
 
 
 
 
Facebook Likes