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 [ 3246 ]
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.
Like Facebook Page https://www.facebook.com/VMwareInsight/
Connect to twitter https://twitter.com/imPranayK
Subscribe my Channel https://www.youtube.com/vmwareinsight
Connect over Linkedin https://in.linkedin.com/in/impranayk
Share this on Social Media

About the Author

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

facebook linkedin twitter G+ VMTN youtube

Thank you for visiting my profile. I am Pranay Jha, bring along a total of 11+ years of extensive experience with me in Information Technology sector for organizations from small business to large enterprises, wherein my current assignment I am associated with IBM as a Technical Solution Architect for Virtualization platform. I am also an Independent blogger and founder of Vmwareinsight.com. I can be reached via email at pranay1988jha@gmail.com or Direct Message via Contact Us form.

 
Please SignUp/Login to comment...

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