Disable 'Bidirectional communication' for a printer?

随声附和 提交于 2020-05-17 06:44:28

问题


How do you disable 'Bidirectional communication' using powershell?

I can see EnableBIDI when running:

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

回答1:


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.

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()

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 }

...or even simplify it to a single cmdlet invocation...

Set-CimInstance -Query 'SELECT * FROM Win32_Printer WHERE Name = ''My Printer Name''' -Property @{ EnableBIDI = $false }


来源:https://stackoverflow.com/questions/48992474/disable-bidirectional-communication-for-a-printer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!