This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.

Set-SNMPTrapCommunity

Synopsis

Configures the SNMP trap communities and destinations on a local or remote computer.

Syntax

  • Set-SNMPTrapCommunity [-TrapCommunity] [-TrapDestination] [-ComputerName] [-Credential]

Description

The Set-SNMPTrapCommunity cmdlet is used to add or remove SNMP trap communities and trap destinations on the local or a remote computer.

Parameters

  • TrapCommunity Add this trap community to the computer. When adding a trap community you must also specify the TrapDestination parameter.
  • TrapDestination Add this trap destination to the specified trap community. When adding a trap destination you must specify the TrapCommunity parameter.
  • ComputerName The computer against which to run the cmdlet. By default this parameter will be populated with the name of the local computer.
  • Credential The credentials under which to run the cmdlet. By default this cmdlet will run as the current user. Using this parameter and the Get-PSCredential cmdlet you can specify an alternate set of credentials under which to execute this command.

Inputs

Set-SNMPTrapCommunity accepts the output of Get-SNMPTrapCommunity as an input object. In addition, the TrapCommunity, TrapDestination and ComputerName parameters each accept pipeline input by property name.

Outputs

Set-SNMPTrapCommunity makes changes directly to Windows and does not output any Powershell objects.

Notes

The Set-SNMPTrapCommunity cmdlet requires that the RPC service is started on the computer it is trying to access and that DNS services are available to resolve target host names.

Example 1

In this command the SNMP service of the local computer is configured to add the trap community monitoring and the trap destination 192.168.1.44:

Set-SNMPTrapCommunity -TrapCommunity Monitoring -TrapDestination 192.168.1.44

Example 2

The Set-SNMPTrapCommunity cmdlet can be used in conjunction with the Get-SNMPTrapCommunity cmdlet. In this example the trap communities and destinations on computer PC01 are replicated on computer PC02:

Get-SNMPTrapCommunity -Computer PC01 | Set-SNMPTrapCommunity -Computer PC02