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
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
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