PoshCode Archive  Artifact [74b8586b7b]

Artifact 74b8586b7b1bbd57db95ab70c70156f6ff47383f811cd3d10524b30209bfbf80:

  • File Send-SNMP-trap.ps1 — part of check-in [50a04999b7] at 2018-06-10 12:57:01 on branch trunk — This will send an SNMP trap to the specified manager (hostname). The script isn’t very flexible, but it’s a good example of how to build traps using SharpSNMPLib. External requirementss: (user: halr9000 size: 1272)

# encoding: ascii
# api: powershell
# title: Send SNMP trap
# description: This will send an SNMP trap to the specified manager (hostname). The script isn’t very flexible, but it’s a good example of how to build traps using SharpSNMPLib. External requirementss:
# version: 1.3.6
# author: halr9000
# license: CC0
# x-poshcode-id: 1413
# x-archived: 2015-07-19T01:35:38
# x-published: 2010-10-22T06:50:00
#
# Two DLLs (see below) from SharpSNMPLib project: http://sharpsnmplib.codeplex.com/
# New-GenericObject.ps1 script from http://www.leeholmes.com/blog/CreatingGenericTypesInPowerShell.aspx (also in poshcode)
#
Param ( $DestinationHost )
Add-Type -Path "C:\Program Files\LeXtudio Software\sharpsnmplib.dll"
Add-Type -Path "C:\Program Files\LeXtudio Software\SharpSnmpLib.Controls.dll"
$manager = [system.Net.Dns]::Resolve( $DestinationHost ).AddressList[0]
$TrapDest = New-Object Net.IPEndPoint( $manager, 162 )

[Lextm.SharpSnmpLib.Messaging.Messenger]::SendTrapV1( $TrapDest,
	[IPAddress]::Loopback,
	[Lextm.SharpSnmpLib.OctetString]"public",
	[Lextm.SharpSnmpLib.ObjectIdentifier]"1.3.6",
	[Lextm.SharpSnmpLib.GenericCode]::ColdStart,
	0,
	0,
	( New-GenericObject.ps1 system.collections.generic.list lextm.sharpsnmplib.variable )
)