VMware Cloud Community
chakoe
Enthusiast
Enthusiast

Copy VIPermission from a Cluster to a Server-Folder

Hi,

how do i copy existing VI-Permissions from a Cluster to a Server-Folder?

I am able to show the existing Permissions, but i don´t know the right way to

read them and write them to a server folder....

Any ideas?

Thx

Chakoe

0 Kudos
2 Replies
LucD
Leadership
Leadership

Does this work for you ?

$clusterName = "MyCluster" 
$folderName = "MyFolder"

$folder
= Get-Folder -Name $folderName
Get-Cluster -Name $clusterName | Get-VIPermission | %{
   
New-VIPermission -Entity $folder -Principal $_.Principal -Role $_.Role -Propagate $_.Propagate -Confirm:$false
}

Note that this will set the inherited permissions from the cluster explictely on the folder.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership

If you only want to copy the explicit permissions on the cluster, and not the inherited ones, you can do.

$clusterName = "MyCluster" 
$folderName
= "MyFolder"
$authMgr
= Get-View AuthorizationManager
$cluster
= Get-Cluster -Name $clusterName
$folder
= Get-Folder -Name $folderName

foreach($perm in $cluster.ExtensionData.Permission){     $role = ($authMgr.RoleList | where {$_.RoleId -eq $perm.RoleId}).Name     New-VIPermission -Entity $folder -Principal $perm.Principal -Role $role -Propagate $perm.Propagate -Confirm:$false
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos