Get-ViPermission | Select Principal gives me a list of AD user groups using vSphere. How do I find out the list of VMs associated with a particular Principal, <domain>\Video Infrastructure, selecting VM name, datastore, and cluster?
Thank you LucD (as always). The following worked like a charm.
$principal = '<domain>\<user_group>'
Get-VM | where{(Get-VIPermission -Entity $_).Principal -contains $principal} |
Select Name,@{N='Datastore';E={(Get-Datastore -RelatedObject $_).Name -join '|'}},
@{N='Cluster';E={(Get-Cluster -VM $_).Name}} | Export-csv c:\users\<me>\<filename.csv> -NoClobber
I will need to tweak this somewhat as a peer mentioned we need the 'vm and templates' folder name as well.
Try something like this
Get-VM | where{(Get-VIPermission -Entity $_).Principal -contains $principal} |
Select Name,@{N='Datastore';E={(Get-Datastore -RelatedObject $_).Name -join '|'}},
@{N='Cluster';E={(Get-Cluster -VM $_).Name}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LucD (as always). The following worked like a charm.
$principal = '<domain>\<user_group>'
Get-VM | where{(Get-VIPermission -Entity $_).Principal -contains $principal} |
Select Name,@{N='Datastore';E={(Get-Datastore -RelatedObject $_).Name -join '|'}},
@{N='Cluster';E={(Get-Cluster -VM $_).Name}} | Export-csv c:\users\<me>\<filename.csv> -NoClobber
I will need to tweak this somewhat as a peer mentioned we need the 'vm and templates' folder name as well.
With Folder:
$principal = '<domain>\<user_group>'
Get-VM | where{(Get-VIPermission -Entity $_).Principal -contains $principal} |
Select Name,Folder,@{N='Datastore';E={(Get-Datastore -RelatedObject $_).Name -join '|'}},
@{N='Cluster';E={(Get-Cluster -VM $_).Name}} | Export-csv c:\users\<me>\<filename.csv> -NoClobber
Now I'm ready to make an environment in vRealize and do forecasting for the group and give them read-only access to the datastores and clusters. Thanks for your help.