header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
add-type works but no joy
Last Post 28 Jul 2010 02:01 PM by Peteski. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
PeteskiUser is Offline
New Member
New Member
Posts:2
Avatar

--
27 Jul 2010 04:01 PM
    I'm not a strong programmer so I'm not sure if I'm just doing this wrong or there is a difference in Windows Server 2008 R2 vs Win7 but I can't get an add-type to work.

    The type is from http://sharpsnmplib.codeplex.com where I'm trying to make use of the snmpget function using code like this:

    Add-Type -Path "C:\SNMP\sharpsnmplib.dll"
    Add-Type -Path "C:\SNMP\SharpSnmpLib.Controls.dll"
    snmpget -v 1 -c public $hostname $oidstring

    It works fine on my windows 7 64 bit workstation but on a windows server 2008 R2 server it throws an error stating it doesn't know what "snmpget" is, meaning it didn't add the type properly.

    I set execution policy and tried it on 64bit and 32bit powershell and no joy.

    Any ideas?

    thanks

    Pete
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1643
    Avatar

    --
    27 Jul 2010 04:13 PM
    Can you try:
    PS>./snmpget -v 1 -c public $hostname $oidstring

    The zip actually provides an .exe for you to use. There's likely actually no need for you to use Add-Type at all to load the .NET libraries using this method.
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    PeteskiUser is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    28 Jul 2010 02:01 PM
    Thanks Marco- I guess I should have tried that as an even simpler implementation. I'd still like to know why the add-type didn't work (or rather how to debug why it didn't work) but this definitely solves the greater problem.

    I also found that I had inititally some trouble with invoking the snmpget.exe from within powershell but I figured it out- I had to separate the arguements (which contained hyphens) using quotes and then I was able to get it to work. snmpget.exe "-v 1" "10.2.60.215" $OIDstring

    Thanks again!

    Pete
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer