# encoding: ascii
# api: powershell
# title: NetSnmp.psm1
# description: Beginnings of a PowerShell v2 module that serves as a convenience wrapper for the Net-SNMP executables.
# version: 0.1
# type: function
# author: halr9000
# license: CC0
# function: Get-SnmpValue
# x-poshcode-id: 1238
# x-archived: 2016-11-07T08:33:05
# x-published: 2009-07-28T12:37:00
#
#
#requires -version 2
$NetSnmp = Join-Path $env:programfiles "Net-SNMP\bin"
	if ( -not ( Test-Path "$NetSnmp\snmpwalk.exe" ) ) {
		Throw "Net-SNMP binaries not found in $NetSnmp. Please install to this folder `
			or edit the NetSnmp variable as appropriate."
	}

# Modeled after SNMPWALK http://www.net-snmp.org/docs/man/snmpwalk.html
function Get-SnmpValue {
	param (
		[Parameter( Position = 0, Mandatory = $true )] $Agent,
		[Parameter( Position = 1, Mandatory = $true )] $OID,
		$Port = 161,
		$Community = "public",
		$Version = "2c"
	)
	&"$NetSnmp\snmpwalk.exe" "-v$Version" "-c$Community" "${Agent}:$Port" "$OID"
}
