VMware Cloud Community
Pinball
Enthusiast
Enthusiast

Update all host SNMP config via PowerCLi

Hi there

I need to update all our hosts with the following details below and found a great script for that but missing the step for updating the last 2 items. The script uses the values position based on "esxcli.system.snmp.get" but i'm unable to see the position for " --hwsrc sensors &  --hwsrc indications". Any idea where i'm going wring?

Values to update:

esxcli system snmp set –c XXXXXXXX

esxcli system snmp set –t 172.22.145.10@162/XXXXXXXXX

esxcli system snmp set –e true

esxcli system snmp set --hwsrc sensors

esxcli system snmp set --hwsrc indications

Script I propose to use:

$esxlist = get-vmhost

$communities = “XXXXXXXXX”

$enable = $true

$port = 162

foreach($item in $esxlist){

Connect-VIServer -Server $item -User root -Password “<rootpassword>”

$esxcli = Get-EsxCli -VMhost $item

$esxcli.system.snmp.set($null,”$communities”,”$enable”)

$esxcli.system.snmp.get()

}

0 Kudos
1 Reply
LucD
Leadership
Leadership

If you call the set method without parameters, you can see where each parameter needs to go

snmp.png


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

0 Kudos