Royston
Royston

Reputation: 598

how to use wmi with powershell to target a specific printer for output

I have an amazing script i am going to use to for a bespoke print solution. There is one thing left to do. The script utilizes Start-Process –FilePath “c:\testfolder\*.docx” –Verb Print

how can i make it so it targets an installed printer on the client system without targeting/using the default printer? (another VBScript already uses the default).

PSVersion5. + W764bit

Upvotes: 1

Views: 568

Answers (2)

Royston
Royston

Reputation: 598

(New-Object -ComObject WScript.Network).SetDefaultPrinter('Xerox Floor X')

This does the trick, it will select the relevant default printer and then i can run another line which will default it back to the original default printer after the script runs.

Some issues with parentheses running and defaulting it back before it prints at the moment though.

Upvotes: 1

Nick
Nick

Reputation: 1863

I dont think you can specify the printer when using the Print verb. What you can do is this:

Get-ChildItem -Path "C:\testfolder" -Filter *.docx | Out-Printer "\\Server01\Prt-6B Color"

Get all items in path with extension .docx pass to Out-Printer

More on Out-Printer

Upvotes: 0

Related Questions