darkbat91 / powershell Goto Github PK
View Code? Open in Web Editor NEWPowershell scripts that are useful
Powershell scripts that are useful
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
Where can I find xml and DLL file required by the script Get-PrinterCounts.ps1?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.