How to set printer permissions using PowerShell / some other script?

Posted by Borek on Super User See other posts from Super User or by Borek
Published on 2012-09-24T08:16:40Z Indexed on 2012/09/24 9:40 UTC
Read the original article Hit count: 344

Filed under:
|
|
|

I need to update printer's permissions in a script, i.e. do the same as I would manually do this way:

  1. Open Devices and Printers applet
  2. Double-click the default printer (open its queue)
  3. Go to Printer -> Properties
  4. In the properties dialog, go to Security tab
  5. Change permissions for Everyone (e.g., check Manage documents permissions)

How to do that? For example, in PowerShell, I can do

Get-WmiObject -class win32_printer -filter Default=True

to get the default printer and there are then methods getSecurityDescriptor() and setSecurityDescriptor() but for instance this command:

(Get-WmiObject -class win32_printer -filter Default=True).getsecuritydescriptor().Descriptor

return null so I'm not sure if I'm doing it the right way.

Does anyone have a working example to set printer permissions? Am I on the right path or should I use something other than WMI entirely? Thanks.

© Super User or respective owner

Related posts about Windows

Related posts about printer