VMware Cloud Community
Sploofer__
Contributor
Contributor

Cannot get both Get-VMHost and Get-VirtualPortGroup to work together

I am trying to write a script that will output which of the Virtual Port Groups have promiscuous mode set to accept. I have been able to get an output of the VPGs and whether they have this set to accept (true) but the output is missing which blade each line refers to. Can anyone help?

What I have so far...

Get-VirtualPortGroup | Get-SecurityPolicy | Where-Object -Property AllowPromiscuous -contains 'True'

I will not bore you with the million attempts I have tried to get this to work. Any help, much appreciated.

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

Something like this.
But be aware that this will only work for VSS

Get-VirtualPortGroup -Standard -PipelineVariable pg | 
Get-securitypolicy | 
where{$_.AllowPromiscuous} | 
Select VirtualPortgroup,
   @{N='VMHost';E={(Get-View -Id $pg.VMHostId).Name}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Sploofer__
Contributor
Contributor

Thank you! That absolutely did the job. I added Format-table VirtualPortGroup, VMHost -Autosize on the end so I could see the full outputs - just in case anyone else uses this in the future. 

Reply
0 Kudos