Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get and set printer ACL in powershell

I would like to grant the group "users" the permission of deleting one printer using powershell.

How can I get the local printer's ACL and include this new ACL to thoses?

Thanks for your help.

like image 727
MUY Belgium Avatar asked Jun 25 '26 09:06

MUY Belgium


2 Answers

Using powershell 4 on my 2012 server I do something like following for deploying our printers.

I create a temporary printer called 'TEMP' in this example and use the Security Tab to define printer permissions I want to have on a particular users printer or set of printers then I get the security descriptor property and dump it into a text file, you can store it to a variable if you like vs. dumping out to a text file like I show here.

(Get-Printer 'TEMP' -Full).PermissionSDDL | Out-File 'C:\OregonOperation.txt'

Then I use something like this to pull my saved Security settings into a variable. $perms = Get-Content 'C:\OregonOperation.txt'

Then to push it to particular printer you can do the following

Set-Printer 'NEWPRINTER' -PermissionSDDL $perms 

If you wanted to target a remote computer, you need to add the -Computer parameter.

Set-Printer 'NEWPRINTER' -PermissionSDDL $perms -Computer 'SOMEWORKSTATION'

Hope this helps.

like image 69
ATek Avatar answered Jun 27 '26 03:06

ATek


Here's what I use to blanket apply permissions across all printer on a print server. Server 2012 powershell v4

Set up a printer permissions for use as a template, and load them permissions into a variable.

$printerperms = (Get-Printer -ComputerName Printsvr -Name admin-printer -Full).PermissionSDDL

Get all printers from the server you wish to apply the permissions to.

$allprinters = get-printer -ComputerName Printsvr -name * | select name -ExpandProperty name

Using a "foreach" command, you can apply the permissions from the template printer and apply said permissions to all using the command below.

foreach ($printer in $allprinters)
{Set-Printer $printer -PermissionSDDL $printerperms -ComputerName Printsvr}
like image 29
Leon Avatar answered Jun 27 '26 03:06

Leon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!