You can try ...
PowerCLI C:\Scripts> $esx_hosts=get-vmhost <your-host-name>
PowerCLI C:\Scripts> foreach ( $esx_h in $esx_hosts) {
>> $esx=Get-EsxCli -VMHost $esx_h.name -V2
>> $snm_get=$esx.system.snmp.get.invoke()
>> write-host "Before" $esx_h.name $snm_get.enable $snm_get.communities
>>
>> }
Before <your-host-name> false ihKtIhKQ4G5L5bdfHor2
PowerCLI C:\Scripts> $snm_get
authentication :
communities : {ihKtIhKQ4G5L5bdfHor2}
enable : false
engineid : 00000063000000a100000000
hwsrc : indications
largestorage : true
loglevel : info
notraps :
port : 161
privacy :
remoteusers :
syscontact :
syslocation :
targets :
users :
v3targets :
PowerCLI C:\Scripts> foreach ( $esx_h in $esx_hosts) {
>> $esx=Get-EsxCli -VMHost $esx_h.name -V2
>> $snm_get=$esx.system.snmp.get.invoke()
>> write-host "Before:" $esx_h.name $snm_get.enable $snm_get.communities
>> $snmpArgs=$esx.system.snmp.set.CreateArgs()
>> $snmpArgs.communities="{}"
>> $snmpArgs.enable="false"
>> $esx.system.snmp.set.invoke($snmpArgs)
>> }
Before: <your-host-name> false ihKtIhKQ4G5L5bdfHor2
true
After: <you-host-name> false
PowerCLI C:\Scripts> $snm_get
authentication :
communities : {}
enable : false
engineid : 00000063000000a100000000
hwsrc : indications
largestorage : true
loglevel : info
notraps :
port : 161
privacy :
remoteusers :
syscontact :
syslocation :
targets :
users :
v3targets :
PowerCLI C:\Scripts>
--------------------above actually didn't work I end up with '{}' string in community name so I run below it seems to work ----------
PowerCLI C:\Scripts> foreach ( $esx_h in $esx_hosts) {
>> $esx=Get-EsxCli -VMHost $esx_h.name -V2
>> $snm_get=$esx.system.snmp.get.invoke()
>> write-host "Before:" $esx_h.name $snm_get.enable $snm_get.communities
>> $snmpArgs=$esx.system.snmp.set.CreateArgs()
>> $snmpArgs.reset="true"
>> $snmpArgs.enable="false"
>> $esx.system.snmp.set.invoke($snmpArgs)
>>
>> }
PowerCLI C:\Scripts> $snm_get
authentication :
communities :
enable : false
engineid :
hwsrc : indications
largestorage : true
loglevel : info
notraps :
port : 161
privacy :
remoteusers :
syscontact :
syslocation :
targets :
users :
v3targets :
:smileywink: