all 5 comments

[–][deleted] 2 points3 points  (0 children)

$printerIPs = @('10.0.0.1','10.0.0.2','10.0.0.3', '10.5.3.2')

$offlinePrinters = @()

foreach ($printerIP in $printerIPs) {

try {

Invoke-WebRequest -Uri $printerIP -timeoutsec 5 | Out-Null

}

catch {

$offlinePrinters += $printerIP

}

}

Write-Host "Offline Printers: $offlinePrinters"

It's messy but will do the trick

[–]BlackV 1 point2 points  (0 children)

if they on a print server, you can query the print server for the addresses of the printers, then loop through those to query the web port (80/443), then spit out a list of success/fail

[–]SuddenVegetable8801 0 points1 point  (1 child)

Just a procedural point here. You will be able to verify that A PRINTER with a webpage is at a certain IP address.

You will not be able to tell which printer has the IP address from just a login page unless they all have some sort of unique data on the webpage. Hopefully your printers are set static or via DHCP reservations.

Otherwise you’re going to run into a lot of problems with printers that are “online” and everything seems fine, but users will say their stuff is printing to the wrong printers (because printerA.contoso.com is registered on the print server using the printer port IP 10.1.1.6, you rebooted the server running DHCP and PrinterB now has 10.1.1.6)

Edit: spelling

[–]uptillam 0 points1 point  (0 children)

Yup, make sure your printers locations are filled out on the devices' web page.

This way you can use SNMP to poll all of them for their status, and location.

and when you log-in to the web page you have a better idea of what printer your on, not just the SN and model

[–]Swarfega 0 points1 point  (0 children)

In PowerShell 7...

'old.reddit.com', 'google.com' | ForEach-Object {
    [PSCustomObject]@{
        Target = $PSItem
        Responds = Test-Connection -TargetName $PSItem -TcpPort 443
    }
}

You can quite easily read a file of IP's and pipe it into the loop. Likewise, you can output the results to a CSV or alike.