Get and set printer ACL in powershell
Solution 1
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.
Solution 2
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}
MUY Belgium
I have a good advise for you : READ THE MANUAL and VALIDATE YOUR DATA!
Updated on June 04, 2022Comments
-
MUY Belgium almost 2 years
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.
-
MUY Belgium over 9 yearsUnforunately, I am working on Windows7 and have not the Get-Printer and Set-Printer functions.
-
ATek over 9 yearsI think Jeroen posted your best bet then. There is also this thread as well that could be useful. serverfault.com/questions/86477/…
-
CitizenRon about 8 yearsWonderful idea ssaviers! This worked perfectly for what I needed today.