user4661402
user4661402

Reputation:

Finding the connectivity status of a printer by share name

I'm currently writing a test-page printing script, and am trying to work out if there is a way of "pinging" a printer when its only known details are share name (eg \SERVERNAME\PRINTER01).

Standard ping messages and test-connection tests don't perform this job as far as I can see. Any ideas of how to make this functionality in Powershell?

Upvotes: 0

Views: 904

Answers (1)

StephenP
StephenP

Reputation: 4081

Assuming you are using a network printer and simply sharing it, try this:

$sharedPrinter = Get-CIMInstance CIM_Printer -ComputerName SERVERNAME |`
                 Where-Object{$_.ShareName -match 'PRINTER01'} |`
                 Select-Object -ExpandProperty PortName
Test-Connection $sharedPrinter

Upvotes: 1

Related Questions