VMware Cloud Community
vmCalgary
Enthusiast
Enthusiast
Jump to solution

Get-VIPermission - get VMs associated with Principal

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?

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
vmCalgary
Enthusiast
Enthusiast
Jump to solution

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.

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

$principal = '<domain>\Video Infrastructure'

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

vmCalgary
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
vmCalgary
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos