Original Message:
Sent: Nov 01, 2024 01:49 PM
From: LucD
Subject: export roles from one vcenter and import to another
Looks like part of the code got dropped in one of the migrations.
Try like this
Import-Csv -Path .\roles.csv -PipelineVariable row |ForEach-Object -Process { $Role = @{ Name = $row.Name Privilege = $row.PrivilegeList.Split("`n") | ForEach-Object { Get-VIPrivilege -Id $_ } Server = $row.vCenter Confirm = $false WhatIf = $true } New-VIRole @Role}
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Nov 01, 2024 01:15 PM
From: Juan Gajardo
Subject: export roles from one vcenter and import to another
When I run the import section I am getting asked to supply a value for the following parameters: Name:. $Role returns my first role export in the CSV. any thoughts?
Original Message:
Sent: Nov 11, 2022 07:35 AM
From: LucD
Subject: export roles from one vcenter and import to another
Export
Get-VIRole |Select @{N='vCenter';E={$_.Uid.Split('@:')[1]}}, Name, @{N='PrivilegeList';E={[string]::Join([char]10,$_.PrivilegeList)}} |Export-Csv -Path .\roles.csv -NoTypeInformation -UseCulture
Import
Import-Csv -Path .\roles.csv -PipelineVariable row |ForEach-Object -Process { $Role = @{ Name = $row.Name Privilege = $row.PrivilegeList.Split("`n") | ForEach-Object { Get-VIPrivilege -Id $_ } Server = $row.vCenter Confirm = $false WhatIf = $true } New-VIRole }
Note that you will have to exclude the system-defined Roles.
They are created automatically, and a user can not create those