Recently I came into a company where their printers were called printer 1, printer 2… and so on and so forth. It was amazing. No one knew which printer went where, and I was asked to make some kind of sense of it. Since I had the support of the people, why not print to all the printers with the printer names. Powershell can do this for you.

First thing first, you will need access to the print server to run this script from. The server will need PowerShell 5.1 or higher.

The Power of this script comes into play with Out-Printer. You will need the printer’s name and a message for that printer. Believe it or not, you can send multiple lines as a message too. Thus, you can create a nice message to print out. The next piece you will need is the Get-Printer command. The below script is a message I printed out at the company. It printed to every printer. of course, I had small trouble with non-physical machines.

Scripts


$Printers = get-Printer 
foreach ($Printer in $Printers) {
$Message = @"
Hello, I am trying to assign printers to computers. I need some information. Please read over this and send the results to <your Email Address>. 

1) Your name.
2) Your Computer name.
3) Your username, What you use to log into the computer with. 
4) This Printers name: $($Printer.name)

To find your computer name follow these instructions:
1) Right-Click the start menu.
2) Click system
3) under "Device Specifications" you will find the device name. Note that name and add it to the reply email. 

your email should look like the one below:

My Name: <Your Name>
Computername: <Your Computer name>
Username: <Your UserName>
Printer: $($Printer.name)

Thank you for your time in this matter. 
"@

    Out-Printer -Name "$($Printer.name)" -InputObject $Message
}

The Break Down

First we grab the printers with the Get-Printer Command.

$Printers = get-Printer 

Then we loop through the printers with a foreach loop. Inside that loop, we will do our work.

foreach ($Printer in $Printers) {}

Next, we create the message we want to print to each printer. We do this by doing a simple variable with what is called a here-string. Here-Strings are large strings that can contain special characters and much more. Oftentimes it’s Contained within @” some data “@. Notice that the $ still triggers variables, and you can still pull items out of variables by using the $($Var.info) options.

$Message = @"
Hello, I am trying to assign printers to computers. I need some information. Please read over this and send the results to <your Email Address>. 

1) Your name.
2) Your Computer name.
3) Your username, What you use to log into the computer with. 
4) This Printers name: $($Printer.name)

To find your computer name follow these instructions:
1) Right-Click the start menu.
2) Click system
3) under "Device Specifications" you will find the device name. Note that name and add it to the reply email. 

your email should look like the one below:

My Name: <Your Name>
Computername: <Your Computer name>
Username: <Your UserName>
Printer: $($Printer.name)

Thank you for your time in this matter. 
"@

Finally we push the information into the Out-Printer command. You will need the name of the printer you wish to print to and the message you want to print.

Out-Printer -Name "$($Printer.name)" -InputObject $Message

That’s it, nothing really much else after that. I hope you all can put this to good use.