How to deploy printer in a GPO via powershell

2022-05-11T14:41:15.9+00:00

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 Learn and only found commands to add registries... I don't know how to add local printers via powershell...

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,812 questions
Windows Server Printing
Windows Server Printing
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Printing: Printer centralized deployment and management, scan and fax resources management, and document services
698 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,627 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Alan Morris 1,331 Reputation points
    2022-05-12T12:11:52.7+00:00

    @Anonymous

    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

    0 comments No comments

  2. Limitless Technology 39,811 Reputation points
    2022-05-16T14:46:51.607+00:00

    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://learn.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--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.