Hi all,
We have a DMZ Vmware cluster & for security reasons our security guys want to be informed on a daily basis if there have been VM's configured with 2 network connections, something they don't allow...
So am trying to do this with Powershell: my idea was to have a script output all the VM's with more than 1 portgroup & possibly listing all the portgroups to which it is attached.
The problem is that I don't know how to filter the VM's with 1 PG connection with the ones that have 2 or more connections.
Anybody an idea ?
Thanks in advance !
Peter
This script prints all guests that have more than 1 network connection.
$vms = Get-VM foreach($vm in $vms){ $pgs = Get-VirtualPortGroup -VM $vm | select Name if($pgs.Count -gt 1){ $pgsLine = "" foreach($pg in $pgs){ $pgsLine += ($pg.Name + " ") } Write-Host $vm.Name $pgsLine } }
Or you could use a one-liner that shows the guestname and the number of portgroups it is connected too.
Get-VM | %{$vm = $_.Name; Get-VirtualPortGroup -VM $_ | Measure-Object | %{Write-Host $vm $_.Count}}
And you can include a filter to only display the guests with more than 1 portgroup.
Get-VM | %{$vm = $_.Name; Get-VirtualPortGroup -VM $_ | Measure-Object | where {$_.Count -gt 1} | %{Write-Host $vm $_.Count}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc
je bent echt geweldig !!
You're truly great
Thanks a million, you saved me a lot of time !!
Peter