vSphere PowerCLI Reference

Set-VMHostSnmp

Synopsis

Updates the host SNMP configuration.

Syntax

Set-VMHostSnmp [-HostSnmp] <VmHostSnmp[]> [-Enabled [<Boolean>]] [-Port <Int32>] [-ReadOnlyCommunity <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-VMHostSnmp [-HostSnmp] <VmHostSnmp[]> [-Enabled [<Boolean>]] [-Port <Int32>] [-ReadOnlyCommunity <String[]>] [-TargetCommunity <String>] [-TargetPort <Int32>] [-TargetHost <String>] -RemoveTarget [-WhatIf] [-Confirm] [<CommonParameters>]
Set-VMHostSnmp [-HostSnmp] <VmHostSnmp[]> [-Enabled [<Boolean>]] [-Port <Int32>] [-ReadOnlyCommunity <String[]>] -TargetCommunity <String> [-TargetPort <Int32>] -TargetHost <String> -AddTarget [-WhatIf] [-Confirm] [<CommonParameters>]
Set-VMHostSnmp [-HostSnmp] <VmHostSnmp[]> [-Enabled [<Boolean>]] [-Port <Int32>] [-ReadOnlyCommunity <String[]>] [-RemoveTarget] -TrapTargetToRemove <TrapTarget> [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version
Get-VMHostSNMP
Test-VMHostSNMP

Detailed Description

Updates 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

NameTypeDescriptionRequired?Pipeline InputDefault Value
HostSnmpVmHostSnmp[]Specify the host Snmp object you want to modify.truetrue (ByValue)
AddTargetSwitchParameterIndicate 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.truefalse
ConfirmSwitchParameterIf 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.falsefalse$true
EnabledBooleanIndicate that the SNMP feature is enabled on the specified host.falsefalse
PortInt32Specify the port on which the host listens to SNMP messages.falsefalse
ReadOnlyCommunityString[]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 @().falsefalse
RemoveTargetSwitchParameterIndicate that you want to remove a trap target from the host SNMP configuration. There are two ways to specify a trap target: 1) pass the trap target to the TrapTargetToRemove parameter; 2) 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).truefalse
TargetCommunityStringSpecify the community identifier of the trap target.falsefalse
TargetHostStringSpecify the identifier of the target host - a host name or an IP address.falsefalse
TargetPortInt32Specify the port on which the target host listens to SNMP messages.falsefalse
TrapTargetToRemoveTrapTargetSpecify 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).truefalse
WhatIfSwitchParameterIndicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falsefalse

Return Type

VmHostSnmp

Notes

The vSphere server must be a connection to an ESX host.

Examples

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

$hostSNMP = Get-VMHostSNMP

Set-VMHostSNMP $hostSNMP -Enabled:$true -ReadOnlyCommunity 'secret'

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.


Copyright © 1998 - 2012 VMware, Inc. All rights reserved.