I'm trying to configure SNMPv3 in ESXi. I've been able to accomplish this on a host using ESXCLI. I need to convert this to a powercli script to deploy to the rest of our environment. The code below works for all snmp parameters except for "users." I'm struggling with the syntax. Note that I'm using ESXCLI version 1 as this is being added to a massive configuration script that was written using version 1.
If I try the following code using a string to enter the "users" properties I get the an error.
PS C:\Users\user1> $esxhost = "labhost.domain.net"
$esxCli = Get-EsxCli -VMHost $esxhost
$esxCli.system.snmp.set("SHA1", "1a2b3c4d5e", $true, "1234567890", "indications", $true, "info", $null, 161, "AES128", $null, $null, $null, $null, "Servmon/123456789/123456789/priv", $null) | out-null
# test outside postinstall
$esxCli.system.snmp.get()
Message: EsxCLI.CLIFault.summary;
InnerText: Can not resolve target destination to IP address: ServmonEsxCLI.CLIFault.summary
At line:3 char:1
+ $esxCli.system.snmp.set("SHA1", "1a2b3c4d5e", $true, "1234567890", "i ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], MethodFault
+ FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.MethodFault
authentication : SHA1
communities : {1a2b3c4d5e}
enable : true
engineid : 1234567890
hwsrc : indications
largestorage : true
loglevel : info
notraps :
port : 161
privacy : AES128
remoteusers :
syscontact :
syslocation :
targets :
users :
v3targets :
If I use $null for "users" property it works.
PS C:\Users\user1> $esxhost = "labhost.domain.net"
$esxCli = Get-EsxCli -VMHost $esxhost
$esxCli.system.snmp.set("SHA1", "1a2b3c4d5e", $true, "1234567890", "indications", $true, "info", $null, 161, "AES128", $null, $null, $null, $null, $null, $null) | out-null
# test outside postinstall
$esxCli.system.snmp.get()
authentication : SHA1
communities : {1a2b3c4d5e}
enable : true
engineid : 1234567890
hwsrc : indications
largestorage : true
loglevel : info
notraps :
port : 161
privacy : AES128
remoteusers :
syscontact :
syslocation :
targets :
users :
v3targets :
This is the ESXCLI code that works.
Configuring SNMP v1/v2c/v3 Using ESXCLI 5.1 - VMware vSphere Blog
esxcli system snmp set –engineid 766d77617265
esxcli system snmp set –authentication SHA1
esxcli system snmp set –privacy AES128
esxcli system snmp hash -r -A secret1234 -X secret5678
esxcli system snmp set –users william/f9f7311379046ebcb5d134439ee5b7754da8a90f/d300f16eec59fb3b7ada7844ff764cbf4641fe5f/priv
esxcli system snmp set –v3targets pod23-esx-01a.pml.local@161/william/priv/trap
esxcli system snmp set –enable true
esxcli system snmp test