Talk:SNMP and PowerShell
really useful info on getting PS to talk to SNMP, thanks.
One thing I can't figure out in your examples though:
PS C:\Users\simon\Documents\Scripts> . .\lib\SNMP-Funcs.ps1 What does this line do? I can't find any reference to a script called SNMP-Funcs.ps1 elsewhere in the article.
I've followed your steps and everything *seems* to be working except I get no output when running the "get" and "walk" scripts and I suspect the above line my be the culprit!
Thanks in advance,
OK, I realize no one has responded in a year, but perhaps someone will find this info useful...
The author is just using a different file name called '. .\lib\SNMP-Funcs.ps1' in his example. It is the same as 'SNMP.ps1'
In the example below, BigDipper is my 'scripts' folder. I have a sub-folder under it called 'lib' with SNMP.ps1 in it and a sub-folder under 'lib' called 'LexTmSharpSNMP' with 'SharpSnmpLib.dll' in it:
PS C:\users\tyson\Downloads\snmp\PowerShell\BigDipper> . .\lib\SNMP.ps1
PS C:\users\tyson\Downloads\snmp\PowerShell\BigDipper> Load-SnmpAssembly | fl
CodeBase : file:///C:/users/tyson/Downloads/snmp/PowerShell/BigDipper/lib/LexTmSharpSNMP/SharpSnmpLib.dll EntryPoint : EscapedCodeBase : file:///C:/users/tyson/Downloads/snmp/PowerShell/BigDipper/lib/LexTmSharpSNMP/SharpSnmpLib.dll FullName : SharpSnmpLib, Version=7.5.10510.1, Culture=neutral, PublicKeyToken=db32884da8b9d0dd GlobalAssemblyCache : False HostContext : 0 ImageFileMachine : ImageRuntimeVersion : v2.0.50727 Location : C:\users\tyson\Downloads\snmp\PowerShell\BigDipper\lib\LexTmSharpSNMP\SharpSnmpLib.dll ManifestModule : SharpSnmpLib.dll MetadataToken : PortableExecutableKind : ReflectionOnly : False
PS C:\users\tyson\Downloads\snmp\PowerShell\BigDipper> Invoke-SNMPget "192.168.1.154" ".18.104.22.168.4.1.322.214.171.124.126.96.36.199.1"
The Wiki is pulling all my spaces out of the output between the final OID and the Data fields. It's returning:
OID = .188.8.131.52.4.1.3184.108.40.206.220.127.116.11.1
Data = 1
I hope these examples help others out.
Request for Invoke-SnmpSet
These scripts have been great in that I can now capture SNMP info into PowerShell objects. It would be even a nicer tool if we could have an additional routine created for setting SNMP values. I'm not strong in C#, but believe this reference could come in handy in writing the script:
Thanks again for putting together these tools!