question

ClaudianorJunior-0129 avatar image
0 Votes"
ClaudianorJunior-0129 asked LimitlessTechnology-2700 answered

How to deploy printer in a GPO via powershell

I'd like to add printers into a GPO via powershell because eventually I need to add 50-100 printers.

This is the process.

201094-registry.png


Then, I need to add printers inside "Control Panel Settings"

201095-printers.png


So, I created the first part of the script:

Set-GPPrefRegistryValue -Name "GPO Name" -Context Computer -Key "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Ports" -ValueName "\\PrintServer\Printer" -Value "" -Type String -Action Create

With this command, I changed the manual proccess in the dialog box

201087-registry2.png


I don't need to do it anymore, but the second part, I still have to...

201068-new-local-printer.png



If I can do it via powershell like the first proccess, I would do it much faster...

May someone help me... I searched on the Microsoft Docs and only found commands to add registries... I don't know how to add local printers via powershell...

windows-server-powershellwindows-group-policywindows-server-print
registry.png (16.7 KiB)
printers.png (15.5 KiB)
registry2.png (13.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TheAlanMorris avatar image
0 Votes"
TheAlanMorris answered

@ClaudianorJunior-0129

The PowerShell command
add-printer

You will need to start the process by adding the print driver but in order to use the PowerShell command
add-printerdriver the driver must first exist in the Windows Driverstore so it's generally easier to use the prndrvr.vbs file to get the driver installed. You can also use the Group Policy Preferences Printers trick to install a driver but I don't recommend it.

You will also need to use the PowerShell command
add-printerport
To add the Standard TCP/IP port to the device.

The PowerShell command
get-help print

Is your friend.

I've installed over 500000 printers using PowerShell. Let me know if you get stuck.

Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hello ClaudianorJunior,

I think you have half of it. The Printer GPO will not allow you to run a Powershell script. The best way to deploy Powershell script for printer deployment would be as a Logon Script. You can create different scripts with the different Printers to be assigned, and then link the specific policy (for Example "Printer001") to the right OU (for example "Users that need the Printer001"). This way, every time the user logs in, you ensure that the printer is reloaded.

There is a very good official article from Microsoft that explains how to configure them: https://devblogs.microsoft.com/scripting/using-group-policy-to-deploy-a-windows-powershell-logon-script/

If you are also interested in the GUI process for GPO, but starting from Print Server role, please check the next:

Steps to deploy Printers Using a Group Policy:

Click Start, point to "Administrative Tools" and then click "Print Management."
Expand "Print Servers" from the left pane and then select the print server from the list.
Click "Printers." Right-click the target device and then select "Deploy With Group Policy."
Click "Browse" and then select the GPO to associate with the printer.
Select "The Users That This GPO Applies to (Per User)" to enable a group of users to access the printer; select "The Users That This GPO Applies to (Per Machine)" to enable a set of computers to access the printer.
Click "Add," then "OK" to deploy the printers to the GPO.

Reference:
https://docs.microsoft.com/en-us/troubleshoot/windows-server/printing/use-group-policy-to-control-ad-printer



--If the reply is helpful, please Upvote and Accept as answer--

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.