简体   繁体   English

如何将 wmi 与 powershell 结合使用以针对特定打印机进行输出

[英]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该脚本利用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). (另一个 VBScript 已经使用默认值)。

PSVersion5. PS版本5。 + W764bit + W764bit

(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.尽管如此,括号运行和在打印之前默认返回的一些问题。

I dont think you can specify the printer when using the Print verb.我认为您在使用Print动词时不能指定打印机。 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获取路径中扩展名为 .docx 的所有项目传递给Out-Printer

More on Out-Printer更多关于 Out-Printer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM