Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Is this in a domain or a workgroup? Also, will you set the permissions for groups, users, or both? –  Nick Sep 24 '12 at 16:31

1 Answer 1

I don't know PowerShell, I have only done printer permissions directly using .NET and WMI, and it can get messy as the permissions are made up of the SecurityDescriptor, which has a Descriptor property, which has a DACL property, which contains one or more Win32_ACE objects, each of which contains AccessMask, AceFlags, and Trustree which is a Win32_Trustee object which contains who the permission applies to.

There maybe a PowerShell addon that simplifies setting the above, alternatively take a look at the SetACL command line tool which you could call from PowerShell.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.