I am trying to obtain folder permissions of datacenter type folder in VCenter and trying to export it onto csv.
Any lead how to do this is much appreciated.
Try something like this
Get-VIPermission |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks I wrote something like this - But I still have one more doubt
Get-Folder -Type Datacenter | Get-VIPermission | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
foreach($folder in Get-Folder -Type Datacenter)
{
foreach ($dc in Get-Datacenter -Location $folder)
{
// How can I get permissions of each datacenter for a particular folder and export it to csv
}
}
Is there a question there?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
yes , I have a question - how can I get the permissions of each datacenter under each folder of type datacenter.
Also I have to export it to csv. I am struck with above snippet.
Did you try like this?
Get-Datacenter |
Get-VIPermission |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No I didnt try this way, let me give it a try.
The snippet gave output which had entity names like screenshot attached.
I wanted the foldernames and datacenter names so I tried something like this
foreach($folder in Get-Folder -Type Datacenter)
{
foreach ($dc in Get-Datacenter -Location $folder)
{
Get-VIPermission -Entity $folder |
Select @{N='Folder'; E={$folder.Name}},
@{N='Datacenter'; E={$dc.Name}},
Role,
Principal,
Propagate,
IsGroup
}
}
} | Export-Csv C:\output\DatacenterPermissions_$CurrentDate.csv -NoTypeInformation -UseCulture
You didn't say which properties you wanted in the CSV.
And I would be very much amazed if that script actually works
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
To do this like earlier
Get-Folder -Type Datacenter |
Get-VIPermission |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
could you tell me how to do it , I need to select the folder name property and find permissions against it.
You could try like this
Get-Datacenter -PipelineVariable dc |
Get-VIPermission |
Select @{N = 'Folder'; E = {$folder.Name}},
@{N = 'Datacenter'; E = {$dc.Name}},
Role,
Principal,
Propagate,
IsGroup |
Export-Csv C:\output\DatacenterPermissions_$CurrentDate.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference