I'm not sure if I'm on the correct way or no, so I'm asking for some guidance 🙂
I'm trying to get all enabled services in all ESXi / vCenter in order to check if the service is set to "AllIP" or to specific IP
#Connect to vCenter Server
Connect-VIServer = "vCenter1","vCenter2","vCenter3","vCenter4"
$VMHosts= Get-VMHost | Get-VMHostFirewallException | Where-Object {$_.Enabled -and ($_.ExtensionData.AllowedHosts.AllIP)}
$Results= @()
foreach ($VMHost in $VMHosts) {
}
I'm not sure what the actual question is and why you have an empty foreach loop in that snippet.
All the info is there
Connect-VIServer = "vCenter1","vCenter2","vCenter3","vCenter4"
Get-VMHost |
Get-VMHostFirewallException |
Where-Object {$_.Enabled -and $_.ExtensionData.AllowedHosts.AllIP} |
Select @{N='VMHost';E={$_.VMHost.Name}},
Name, Protocols, IncomingPorts, OutgoingPorts, ServiceRunning
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The Get-VMHost should do that.
Unless your vCenters are not configured in LinkedMode, then you will have to run the same for each vCenter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If you get all the ESXi nodes for all vCenters, you can include the vCenter.
Connect-VIServer = "vCenter1","vCenter2","vCenter3","vCenter4"
Get-VMHost |
Get-VMHostFirewallException |
Where-Object {$_.Enabled -and $_.ExtensionData.AllowedHosts.AllIP} |
Select @{N='vCenter';E={([uri]$_.VMHost.ExtensionData.Client.ServiceUrl).Host}},
@{N='VMHost';E={$_.VMHost.Name}},
Name, Protocols, IncomingPorts, OutgoingPorts, ServiceRunning
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If you filter on AllIP there are no individual allowed IP addresses in the result.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference