Advertisement

news | articles | utilities | resources | about

News

Export VC Permissions

Should you ever need to rebuild your vCenter server... perhaps you want to go with a clean install vs. an upgrade for vSphere 4.0, there are a couple of bits of information that you'll want to keep. Namely: your DRS rules; the permissions that you've set up; cluster properties such as DRS automation level, HA, advanced prperties etc; and any custom attributes that you've populated. VMTN forum member LucD has shown us how to export all of our DRS rules, and now LucD has created a powershell script to export all of your vCenter permissions into a plain text document. I should also note that if you choose to do a clean install, you will also lose your performance data that you've been gathering. This can also be useful if you reach the limitations of a single vCenter server and need to replicate permissions to a second ( or third, or fouth ) vCenter.


[permission-export.ps1]

filter Get-Permissions{
$object = Get-View -Id $_.ID
if($object.Name -ne "vm" -and $object.Name -ne "host"){
$perms = $authMgr.RetrieveEntityPermissions($object.MoRef, $false)

if($perms.Count -gt 0){
$path = get-path $object
foreach($perm in $perms){
foreach($role in $authMgr.RoleList){
if($role.RoleId -eq $perm.RoleId){
$row = "" | select roleName, objName, principalName
$row.roleName = $role.Name
$row.objName = $path
$row.principalName = $perm.Principal
$row
}
}
}
}
}
}

function get-path($entity){
$path = $entity.Name
while($entity.Parent -ne $null){
$entity = Get-View -Id $entity.Parent
if($entity.Name -ne "vm" -and $entity.Name -ne "host"){
$path = $entity.Name + "\" + $path
}
}
return $path
}

$authMgr = Get-View AuthorizationManager

Get-Inventory | Get-Permissions | Export-Csv -Path "C:\permissions.csv" -NoTypeInformation

Labels: vCenter permission export

Posted by Dominic Rivera at Thursday, June 11, 2009.


Archives

10/01/2006 - 11/01/2006 | 03/01/2007 - 04/01/2007 | 04/01/2007 - 05/01/2007 | 05/01/2007 - 06/01/2007 | 06/01/2007 - 07/01/2007 | 07/01/2007 - 08/01/2007 | 09/01/2007 - 10/01/2007 | 10/01/2007 - 11/01/2007 | 11/01/2007 - 12/01/2007 | 12/01/2007 - 01/01/2008 | 01/01/2008 - 02/01/2008 | 02/01/2008 - 03/01/2008 | 03/01/2008 - 04/01/2008 | 04/01/2008 - 05/01/2008 | 05/01/2008 - 06/01/2008 | 06/01/2008 - 07/01/2008 | 08/01/2008 - 09/01/2008 | 09/01/2008 - 10/01/2008 | 10/01/2008 - 11/01/2008 | 03/01/2009 - 04/01/2009 | 06/01/2009 - 07/01/2009 |

 
Copyright © 2007 - vmprofessional. All rights reserved.