Hi,
I am trying to export the Permission from vCenter and how can I get the Datastore permission exported for below script
Get-VIPermission |
Select @{N='vCenter';E={$_.Uid.Split('@:')[1]}},
Principal,Role,Propagate,
@{n='Entity';E={$_.Entity.Name}},
@{N='Entity Type';E={$_.EntityId.Split('-')[0]}},
@{N='VMHost';E={$script:vmhost = Get-View -Id (Get-View -Id $_.Entity.Id).Host
$script:vmhost.Name -join '|'}},
@{N='Network';E={
$net = $_.Entity.Id
$script:vmhost.Network.Where{$_ -eq $net} -join '|'}} | Export-Excel -Path $reportName -WorksheetName Permissions
Try like this
Get-VIPermission |
Select @{N='vCenter';E={$_.Uid.Split('@:')[1]}},
Principal,Role,Propagate,
@{n='Entity';E={$_.Entity.Name}},
@{N='Entity Type';E={$_.EntityId.Split('-')[0]}},
@{N='VMHost';E={$script:vmhost = Get-View -Id (Get-View -Id $_.Entity.Id).Host
$script:vmhost.Name -join '|'}},
@{N='Datastore';E={$_.Entity.Name}},
@{N='Network';E={
$net = $_.Entity.Id
$script:vmhost.Network.Where{$_ -eq $net} -join '|'}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Do you have explicit permissions on datastores, or all the permissions inherited?
To see all permissions on each datastore you could do something like this
Get-Datastore -PipelineVariable ds |
Get-VIPermission |
Select-Object -Property @{N='Datastore';E={$ds.Name}},
Principal, Role, Propagate,
@{N = 'Entity'; E = { $_.Entity.Name} }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
We have explicit permissions defined on datastores, so how can I tried as below but Datastore field shows blank
Get-VIPermission |
Select @{N='vCenter';E={$_.Uid.Split('@:')[1]}},
Principal,Role,Propagate,
@{n='Entity';E={$_.Entity.Name}},
@{N='Entity Type';E={$_.EntityId.Split('-')[0]}},
@{N='VMHost';E={$script:vmhost = Get-View -Id (Get-View -Id $_.Entity.Id).Host
$script:vmhost.Name -join '|'}},
@{N='Datastore';E={Get-Datastore $_.Name}},
@{N='Network';E={
$net = $_.Entity.Id
$script:vmhost.Network.Where{$_ -eq $net} -join '|'}} | Export-Excel -Path $reportName -WorksheetName Permissions
Try like this
Get-VIPermission |
Select @{N='vCenter';E={$_.Uid.Split('@:')[1]}},
Principal,Role,Propagate,
@{n='Entity';E={$_.Entity.Name}},
@{N='Entity Type';E={$_.EntityId.Split('-')[0]}},
@{N='VMHost';E={$script:vmhost = Get-View -Id (Get-View -Id $_.Entity.Id).Host
$script:vmhost.Name -join '|'}},
@{N='Datastore';E={$_.Entity.Name}},
@{N='Network';E={
$net = $_.Entity.Id
$script:vmhost.Network.Where{$_ -eq $net} -join '|'}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That worked. Thank you very much 🙂