< Back

Set-VMHostSnmp

Sun Jan 19, 2020 7:11 pm

NAME Set-VMHostSnmp



SYNOPSIS

This cmdlet modifies the host SNMP configuration.





SYNTAX

Set-VMHostSnmp [-HostSnmp] <VmHostSnmp[]> -AddTarget [-Enabled <Boolean>] [-Port <Int32>] [-ReadOnlyCommunity

<String[]>] -TargetCommunity <String> -TargetHost <String> [-TargetPort <Int32>] [-Confirm] [-WhatIf]

[<CommonParameters>]



Set-VMHostSnmp [-HostSnmp] <VmHostSnmp[]> [-Enabled <Boolean>] [-Port <Int32>] [-ReadOnlyCommunity <String[]>]

-RemoveTarget [-TargetCommunity <String>] [-TargetHost <String>] [-TargetPort <Int32>] [-Confirm] [-WhatIf]

[<CommonParameters>]



Set-VMHostSnmp [-HostSnmp] <VmHostSnmp[]> [-Enabled <Boolean>] [-Port <Int32>] [-ReadOnlyCommunity <String[]>]

[-RemoveTarget] -TrapTargetToRemove <TrapTarget> [-Confirm] [-WhatIf] [<CommonParameters>]





DESCRIPTION

This cmdlet modifies the host SNMP configuration. If specified, adds or removes a trap target (removing can be

specified by either TrapTargetToRemove parameter or by any of the following parameters (or combination of them):

TargetCommunity, TargetHost, TargetPort). If the user passes $null, an empty array or string to the

ReadOnlyCommunities parameter, the old values of this property are erased. This results in a NULL value of this

property of the output object.





PARAMETERS

-AddTarget [<SwitchParameter>]

Indicates that you want to add a new trap target to the host SNMP configuration. A trap target consists of

three elements - Community (mandatory), HostName (mandatory), Port (optional - defaults to 162), specified by

the TargetCommunity, TargetHost, and TargetPort parameters.



Required? true

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Enabled <Boolean>

Indicates that the SNMP feature is enabled on the specified host.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-HostSnmp <VmHostSnmp[]>

Specifies the host Snmp object you want to modify.



Required? true

Position? 1

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Port <Int32>

Specifies the port on which the host listens to SNMP messages.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ReadOnlyCommunity <String[]>

Provide a list of communities, identifying who is able to send SNMP requests to that host. If $null, an empty

array or string are passed to this parameter, its old values are erased and the output object for the

ReadOnlyCommunity property is an empty array. In PowerShell an empty array is defined by @().



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-RemoveTarget [<SwitchParameter>]

Indicates that you want to remove a trap target from the host SNMP configuration. There are two ways to

specify a trap target: * Pass the trap target to the TrapTargetToRemove parameter.



* Use a combination of the TargetCommunity, TargetHost, and TargetPort parameters to specify a criteria (for

example, remove all trap targets that are using port 162).



Required? true

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-TargetCommunity <String>

Specifies the community identifier of the trap target.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-TargetHost <String>

Specifies the identifier of the target host - a host name or an IP address.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-TargetPort <Int32>

Specifies the port on which the target host listens to SNMP messages.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-TrapTargetToRemove <TrapTarget>

Specifies the trap target you want to remove. The trap target can be obtained from the "TrapTargets" property

of the HostSNMP object (an array of TrapTarget objects).



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Confirm [<SwitchParameter>]

If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false,

the cmdlet runs without asking for user confirmation.



Required? false

Position? named

Default value $true

Accept pipeline input? False

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are

modified.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

Zero or more modified VmHostSnmp objects







NOTES





You must be connected to the ESX/ESXi host directly.



-------------------------- Example 1 --------------------------



$vmhostSNMP = Get-VMHostSNMP



Set-VMHostSNMP $vmhostSNMP -Enabled:$true -ReadOnlyCommunity 'example-community'



Enables SNMP on a virtual machine host.

-------------------------- Example 2 --------------------------



Get-VMHostSnmp | Set-VMHostSnmp -ReadonlyCommunity @()



Sets the virtual machine host SNMP by erasing the old value of the ReadOnlyCommunity parameter.



RELATED LINKS

Online Version: https://code.vmware.com/doc/preview?id= ... tSnmp.html

Get-VMHostSNMP

Test-VMHostSNMP