Hi all,
I have the following script that works when connecting directly to an esxi host...need to modify this so I can attach to the vcenter so I can only run it once as opposed to on each host.
Basically I am trying to add a single IP address to one of the rulesets on all the hosts.
(Get-VMHost $esxhost )
$esxcli = Get-EsxCli -VMHost $esxhost
$esxcli.network.firewall.ruleset.allowedip.add("10.10.10.10", "vSphereClient")
This is probably simple, but when I try a FOREACH statement it just doesn't work. Not very proficient with powercli
Any help would be appreciated!
Try like this
Get-VMHost | %{
$esxcli = Get-EsxCli -VMHost $_
$esxcli.network.firewall.ruleset.allowedip.add("10.10.10.10", "vSphereClient")
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
Get-VMHost | %{
$esxcli = Get-EsxCli -VMHost $_
$esxcli.network.firewall.ruleset.allowedip.add("10.10.10.10", "vSphereClient")
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
To run the script on all of the hosts, you can use the following command:
(Get-VMHost | Get-EsxCli).network.firewall.ruleset.allowedip.add("10.10.10.10", "vSphereClient")
Thanks for the replies! LucD that worked like a charm, thanks a million.