The script itself is pretty straight forward, the more time consuming is getting the privilege lists. So here you are:
And now for the actual scripting part:
$role = "Veeam Backup Server role" $rolePrivilegesFile = "veeam_vc_privileges.txt" $vCenterServer = "your-vcenter-server-FQDN" Connect-VIServer -server $vCenterServer $roleIds = @() Get-Content $rolePrivilegesFile | Foreach-Object{ $roleIds += $_ } New-VIRole -name $role -Privilege (Get-VIPrivilege -Server $vCenterServer -id $roleIds) -Server $vCenterServer
The script will create a new vCenter Server role assigning it privileges from the file given as input.
If you ever require to get the privileges from vCenter Server then the next piece of code will help (thanks to VMware communities)
$role = "VBR Role" Get-VIPrivilege -Role $role | Select @{N="Privilege Name";E={$_.Name}},@{N="Privilege ID";E={$_.ID}}
You will use the privilege ID format for creating the new role.
No comments:
Post a Comment