VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Export Datastore Permission

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

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

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

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

That worked. Thank you very much 🙂

Reply
0 Kudos