Code Monkey home page Code Monkey logo

powershell's People

Contributors

darkbat91 avatar gjoiner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

powershell's Issues

Get-PrinterCounts.ps1 return no data

I hope that eventually have the correct format for the cxml (testing with 1 printer)

<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <Obj RefId="0">
    <TN RefId="0">
      <T>System.Management.Automation.PSCustomObject</T>
      <T>System.Object</T>
    </TN>
    <MS>
      <S N="PrinterManufacturer">Sharp</S>
      <S N="PrinterIP">10.10.20.22</S>
    </MS>
  </Obj>
</Objs>

dll from: https://www.nuget.org/packages/Lextm.SharpSnmpLib
is loaded from C:\PSScripts\SharpSnmpLib.dll

.ps1 runs with no error, .log gets created but no output csv with any data

Started INFO Logging for Get-PrinterCounts at 2024-01-18 12:48:12
Script Version: 1

Any ideas?

If I run it by hand I get:

PS C:\PSScripts> #Color Pages Sharp
PS C:\PSScripts> $OIDColorSharp = ".1.3.6.1.4.1.2385.1.1.19.2.1.3.5.4.63"
PS C:\PSScripts> #BW Pages Sharp
PS C:\PSScripts> $OIDBWSharp = ".1.3.6.1.4.1.2385.1.1.19.2.1.3.5.4.61"

### Functions ###

function Invoke-SnmpWalk1 ([string]$sIP, $sOIDstart, [string]$Community = "public", [int]$UDPport = 161, [int]$TimeOut=3000) {
    [System.Reflection.Assembly]::LoadFile((Resolve-path C:\PSScripts\SharpSnmpLib.dll))
    #> $null
    # $sOIDstart
    # $TimeOut is in msec, 0 or -1 for infinite
 
    # Create OID object
    $oid = New-Object Lextm.SharpSnmpLib.ObjectIdentifier ($sOIDstart)
 
    # Create list for results
    $results = New-Object 'System.Collections.Generic.List[Lextm.SharpSnmpLib.Variable]' # PowerShell v3
 
    # Create endpoint for SNMP server
    $ip = [System.Net.IPAddress]::Parse($sIP)
    $svr = New-Object System.Net.IpEndPoint ($ip, 161)
 
    # Use SNMP v2 and walk mode WithinSubTree (as opposed to Default)
    $ver = [Lextm.SharpSnmpLib.VersionCode]::V2
    $walkMode = [Lextm.SharpSnmpLib.Messaging.WalkMode]::WithinSubtree
 
    # Perform SNMP Get
    try {
        [Lextm.SharpSnmpLib.Messaging.Messenger]::Walk($ver, $svr, $Community, $oid, $results, $TimeOut, $walkMode)
    } catch {
        Write-Host "SNMP Walk error: $_"
        Return $null
    }
 
    $res = @()
    foreach ($var in $results) {
        $line = "" | Select OID, Data
        $line.OID = $var.Id.ToString()
        $line.Data = $var.Data.ToString()
        $res += $line
    }
 
    $res
}
$DebugPreference = "Continue"
Write-Debug -Message "Loaded Functions"

PS C:\PSScripts> Invoke-SnmpWalk1 -sIP 10.10.20.22 -sOIDstart $OIDColorSharp

GAC    Version        Location
---    -------        --------
False  v4.0.30319     C:\PSScripts\SharpSnmpLib.dll
0

I can get the correct values just fine with

snmpwalk -C:c -v:2 -c:public -r:10.10.20.22 -t:10 -os:.1.3.6.1.4.1.2385.1.1.19.2.1.3.5.4.60 -op:.1.3.6.1.4.1.2385.1.1.19.2.1.3.5.4.63

DLL and XML file

Where can I find xml and DLL file required by the script Get-PrinterCounts.ps1?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.