Powershell scripts to set up default printer

Kevin Arc 1 Reputation point
2021-12-16T08:28:48.087+00:00

Hi,

I want to set up default printer for all the users in the company. I can run the scripts without error. However, The default printer can't be set successfully. I tried many ways to do it without success but no error. I found that if the computer has no default printer set before, then the scripts will not work. If it has a default printer, the the script is successful to set it as default. The following is the scripts, please help.
$ArrPrint = Get-Printer -Name "My printer"
Foreach ($Printer in $ArrPrint){
(Get-WMIObject -ClassName win32_printer | Where-Object -Property Name -eq $($Printer.name)).SetDefaultPrinter() | Out-Null
}

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,364 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Kevin Arc 1 Reputation point
    2021-12-20T02:06:51.367+00:00

    Thanks. But this not work for me. Many of our extsing laptops are newly installed. Our users has no default printer set on their computer. If they have a default printer on laptop, then my script will work without issue to change it to a new default laptop.

    0 comments No comments

  2. Limitless Technology 39,351 Reputation points
    2022-01-06T14:53:59.373+00:00

    Hello @Kevin Arc

    I can recommend to set up a GPO to define first a default printer at first logon into the machines then you would be able to workaround the "empty" default printer issue.

    There is a previous post with different suggestions on how to follow the process: https://social.technet.microsoft.com/Forums/security/en-US/56a2b844-77b9-4935-9932-b226264f129b/set-default-printer-for-all-users-domain-pc?forum=win10itprogeneral

    Hope this helps with your query,

    -----------

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

    0 comments No comments

  3. Limitless Technology 39,351 Reputation points
    2022-01-06T14:53:59.713+00:00

    Hello @Kevin Arc

    I can recommend to set up a GPO to define first a default printer at first logon into the machines then you would be able to workaround the "empty" default printer issue.

    There is a previous post with different suggestions on how to follow the process: https://social.technet.microsoft.com/Forums/security/en-US/56a2b844-77b9-4935-9932-b226264f129b/set-default-printer-for-all-users-domain-pc?forum=win10itprogeneral

    Hope this helps with your query,

    -----------

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

    0 comments No comments