Set Default Printer for all users via powershell remotely -- new request

Let’s say my company has 20 workstations, 10 users, each workstation connect to that 10 printers , and all that 10 users have chance to log into that 20 workstations .

Sometimes , some users try to print document without choosing the correct printer which is the most close to her.

So what I want to know is how to set a default printer for all users on the same workstation remotely .

From google, I found some one modifies the registry to achieve this. but not I want . I hope a powershell version work like this :

Set-DefaultPrinter -name printername -user all(or single user)

BR

Why not use a GPO for this ?

I agree, a gpo would be a better option to set the default printer, but if you needed it for a quick fix, you can run:

# On localhost
(Get-WMIObject -ClassName win32_printer |Where-Object -Property Name -eq "\\printsrv\printer1").SetDefaultPrinter()

# On remote computer
(Get-WMIObject -ComputerName client1 -ClassName win32_printer |Where-Object -Property Name -eq "\\printsrv\printer1").SetDefaultPrinter()

pwshliquori

You can only do it for one user at a time. As a login script, it would work. Otherwise group policy preferences.

$printerObject = Get-WmiObject win32_printer | where name -eq \\$server\$defaultprinter
$result = $printerObject.SetDefaultPrinter()
"default \\$server\$printer $($result.returnvalue)"

Thank you