禁用打印机的“双向通信"? [英] Disable 'Bidirectional communication' for a printer?
问题描述
如何使用 powershell 禁用双向通信"?
How do you disable 'Bidirectional communication' using powershell?
运行时可以看到EnableBIDI
:
get-WmiObject -class Win32_printer | fl *
但是当我尝试这个时,它说没有找到该属性?
But when I try this, it says the property was not found?
Set-PrinterProperty -PrinterName "Some Printer" -PropertyName "EnableBIDI" -Value $False
推荐答案
您正在混合来自两个不同 WMI 类的属性.Set-PrinterProperty
操作来自 root/standardcimv2
命名空间的未记录的 MSFT_PrinterProperty
类,它具有与 Win32_Printer
类 在您之前的命令中.
You are mixing properties from two different WMI classes. Set-PrinterProperty
manipulates instances of the undocumented MSFT_PrinterProperty
class from the root/standardcimv2
namespace, which has different properties than the Win32_Printer
class in your previous command.
相反,操作 Win32_Printer
类的所需实例,因为它具有您想要的属性,然后调用 Put()
提交更改.这在以高程运行时对我有用:
Instead, manipulate the desired instance of the Win32_Printer
class since that has the property you want, then call Put()
to commit the change. This works for me when run with elevation:
$printer = Get-WmiObject -Class 'Win32_Printer' -Filter 'Name = ''My Printer Name'''
$printer.EnableBIDI = $false
$printer.Put()
使用较新的CimCmdlets
模块,您可以使用 Get-CimInstance
以类似方式进行更改 和 Set-CimInstance
cmdlet...
Using the newer CimCmdlets
module you can make that change in similar fashion using the Get-CimInstance
and Set-CimInstance
cmdlets...
$printer = Get-CimInstance -ClassName 'Win32_Printer' -Filter 'Name = ''My Printer Name'''
$printer.EnableBIDI = $false
Set-CimInstance -InputObject $printer
...或将其简化为单个管道...
...or simplify it to a single pipeline...
Get-CimInstance -ClassName 'Win32_Printer' -Filter 'Name = ''My Printer Name''' `
| Set-CimInstance -Property @{ EnableBIDI = $false }
...甚至将其简化为单个 cmdlet 调用...
...or even simplify it to a single cmdlet invocation...
Set-CimInstance -Query 'SELECT * FROM Win32_Printer WHERE Name = ''My Printer Name''' -Property @{ EnableBIDI = $false }
这篇关于禁用打印机的“双向通信"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!