Hello I got my roles exported with the permissions assigned too them now I want to import them but cant find script online that actually work can someone assist please
Without knowing how and what you exported that will be difficult.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello @LucD
Thank you, please see below what I used
#vCenter Role & Permission export#
Write-Host "`tExporting Permissions and Roles for vCenter.."
#$vCenterHost = Read-Host "Vcenter"
try {
#Establishing connection to vCenter
Connect-VIServer -Server vcenter -user
#Permissions
$Permission = Get-VIPermission | Select-Object @{N='vCenter';E={$_.Uid.Split('@:')[1]}},
Principal,Role,propagate,
@{n='Entity';E={$_.Entity.Name}},
@{N='Entity Type';E={$_.EntityId.Split('-')[0]}}
#Export to CSV
$Permission | Export-Csv -Path "C:\Temp\$vCenterHost-Permission.csv"
#Export to XML
$PermissionXML = Get-VIPermission
$PermissionXML | Export-Clixml -Path "C:\Temp\$vCenterHost-Permission.xml"
#Roles
$Role = Get-VIRole | Select-Object @{N='vCenter';E={$_.Uid.Split('@:')[1]}},
Name,
@{N='PrivilegeList';E={[string]::Join([char]10,$_.PrivilegeList)}}
#Export to CSV
$Role | Export-Csv -Path "C:\Temp\$vCenterHost-Roles.csv"
#Export to XML
$RoleXML = Get-VIRole
$RoleXML | Export-Clixml -Path "C:\Temp\$vCenterHost-Roles.xml"
Write-Verbose "`tRole & Permission Data Exported Successfully from $vCenterHost" -Verbose
Write-Verbose "Disconnecting from $vCenterHost" -Verbose
Disconnect-VIServer -Server
}
catch {
Write-Verbose "`tError Encountered! Error:$_" -Verbose
$ErrorObject = New-Object -TypeName PSObject -Property @{
vCenterName = $vCenterHost
Error = $_
}
}
The thread where you got this code from also contains the import code.
See vCenter Roles and Permissions Export and Import (2... - VMware Technology Network VMTN
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference