Script: Set Default Printer (GUI)

Printers are not the easiest things to install and manage for experienced IT professionals, let alone for the typical end user.

There was a need for the clients I interact with to be able to quickly identify which printer is their default and to be able to switch simply. Without having to worry about navigating the windows settings.

The below solution may not have the sharpest look but it is functional and can be tidied up if you have the need and time to do it.

The solution is a PowerShell script that when run will open a Windows Form. It will list all of the installed printers on a machine and also display the current default Printer.

The end-user can select from the list of printers and click “Set Default” to change the default to the selected printer.

Click here to download a zipped folder that contains a compiled exe of the script.
This makes it simple for the end-user to just click to run, instead of dealing with needing to know how to run a script.
You can also then store it somewhere centrally and deploy a shortcut to it with group policy for easy access to all users.

$Printers = Get-WmiObject -Class Win32_Printer | Select-Object -ExpandProperty name
$currentPrinter = Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$true" | Select-Object -ExpandProperty name

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName PresentationFramework

$Form = New-Object system.Windows.Forms.Form
$Form.Text                      = "Default Printer Setup"
$Form.BackColor                 = "#d7ebfe"
$Form.TopMost                   = $true
$Form.Width                     = 800
$Form.Height                    = 500
$Form.StartPosition             = "CenterScreen"
$Icon                           =  [System.Drawing.Icon]("$PSScriptRoot\logo.ico")
$Form.Icon                      = $Icon

$lb_availablePrinters = New-Object
$lb_availablePrinters.Text = "Available Printers"
$lb_availablePrinters.AutoSize = $true
$lb_availablePrinters.Width = 25
$lb_availablePrinters.Height = 10
$lb_availablePrinters.location = new-object system.drawing.point(8,117)
$lb_availablePrinters.Font = "Verdana,25"

$lb_defaultPrinter = New-Object
$lb_defaultPrinter.Text = "Current Default Printer"
$lb_defaultPrinter.AutoSize = $true
$lb_defaultPrinter.Width = 25
$lb_defaultPrinter.Height = 10
$lb_defaultPrinter.location = new-object system.drawing.point(372,117)
$lb_defaultPrinter.Font = "Verdana,25"

$lb_heading = New-Object
$lb_heading.Text = "Default Printer Setup"
$lb_heading.AutoSize = $true
$lb_heading.Width = 25
$lb_heading.Height = 10
$lb_heading.location = new-object system.drawing.point(156,28)
$lb_heading.Font = "Verdana,30,style=Underline"

$bt_close = New-Object
$bt_close.Text = "Close"
$bt_close.ForeColor = "#251c53"
$bt_close.Width = 145
$bt_close.Height = 33
$bt_close.location = new-object system.drawing.point(462,374)
$bt_close.Font = "Verdana,15,style=Bold"

$lb_printer = New-Object
$lb_printer.Text = "$currentPrinter"
$lb_printer.AutoSize = $true
$lb_printer.Width = 270
$lb_printer.Height = 50
$lb_printer.location = new-object system.drawing.point(442,186)
$lb_printer.Font = "Verdana,15"

$lstBX_printers = New-Object
$lstBX_printers.Width = 270
$lstBX_printers.Height = 144
$lstBX_printers.location = new-object system.drawing.point(20,186)
foreach ($Printer in $Printers)
    $Global:currentPrinter = $lstBX_printers.SelectedItem

$bt_setDefault = New-Object
$bt_setDefault.Text = "Set Default"
$bt_setDefault.ForeColor = "#251c53"
$bt_setDefault.Width = 145
$bt_setDefault.Height = 33
    (New-Object -ComObject WScript.Network).SetDefaultPrinter($Global:currentPrinter)
    $lb_printer.Text = "$Global:currentPrinter"
$bt_setDefault.location = new-object system.drawing.point(121,373)
$bt_setDefault.Font = "Verdana,15,style=Bold"


Empty Recycle Bin for all User Accounts


This is a useful one liner to help feel up some space on multi-user systems.

If a user is not aware of [shift + delete] to by pass the recycle bin (free tip if you weren’t aware) they will likely not think to empty the recycle bin and not actually free up any space as a result.
Multiply this by multiple users and it can soon start adding up.

If you need to free up space quickly or just generally tidying up the following can be a quick and easy way to claw back some space.


  1. Open up a command prompt window as an administrator.
  2. Type in or copy/paste the following line and hit return.
rd /s /q %systemdrive%\$RECYCLE.BIN

If the no errors are returned then the command executed successfully and all user recycle bins should now be empty.


The following is a quick explanation of what the different parts of the command mean.

rd(Command) Deletes a directory.
/s(Switch/Option/Flag) Deletes the specified directory as well as subdirectories and all contents.
/q(Switch/Option/Flag) Quiet mode. Will not prompt for confirmation so will carry out command without any interaction
%systemdrive%\$RECYCLE.BINThe path to the directory to delete in this case “%systemdrive%” is a variable for the drive letter that Windows is installed on. “$RECYCLE.BIN” is the location of where all user recycle bins are held.

Command Documentation: rd | Microsoft Docs

Copyright CTlogic 2022