Поиск портов принтера по SNMP

param( $strcomputer="localhost", $network="192.168", $help)
function funHelp()
{
$helpText=@"
DESCRIPTION:
NAME: FindPrinterPorts.ps1
Allows for the management of printer ports on a local or remote machine.

PARAMETERS: 
-computerName Specifies the name of the computer upon which to run the script
-help         prints help file
-network      IP address one, two, or three octets 


SYNTAX:
FindPrinterPorts.ps1 -comptuerName MunichServer 
  Lists all the printer ports on a computer named MunichServer

FindPrinterPorts.ps1 -help ?
  Prints the help topic for the script

FindPrinterPorts.ps1 -computername MunichServer -network "10"
 Sets a class A network address of 10 on the remote server munich server. Only
 Printer ports assigned to the 10.x.x.x range will be returned 

FindPrinterPorts.ps1 
 Returns printer ports in the 192.168.x.x range on the local machine

"@
$helpText
exit
}

if($help) { "Printing help now..." ; funHelp }
$class = "Win32_TcpIpPrinterPort"

Write-Host -foregroundColor Yellow "Below are printer ports in the $network range:`n"
Get-WmiObject -class $class -computername $strcomputer | 
where-object { $_.name -match $network } | foreach($_){ 
 
 if($($_.SNMPEnabled))
 {
  Write-Host -foregroundColor yellow "`tFollowing printer is SNMP enalbled" 
  Write-Host "`t$($_.name), $($_.portNumber), $($_.SNMPCommunity, $($_.SNMPDevIndex)`n" 
 }
 ELSE 
 {
  Write-Host -foregroundColor yellow "`tFollowing printer is NOT SNMP enabled`n"
  write-host "`t$($_.name), $($_.portNumber)"  
 }
}

Также интересно:

0
Голосов пока нет

Оставить комментарий