#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog
>

How to change printer paper size using PowerShell?

koskila
Reading Time 4 min
Word Count 656 words
Comments 3 comments
Rating 5 (1 votes)
View

This article explains (with conveniently copy-pasteable code samples) how you can query your printers using PowerShell and modify properties, such as paper size, for one or more of them. This is very useful if you have multiple printers and multiple computers that you use. AND if you frequently move between continents, you might face the same, totally typical and widespread issue:

Your favorite printer might default to using "Letter" paper size, but you'd really need to get it printed in that sweet, sweet "A4" instead. And boy, what a mess it is if you forget to change it when you're printing!

Margins get messed up. It's the worst.

So, how do you change the default paper size for a printer?

Well, it's actually really easy to do manually. It's so easy that I'm not even going to go into the details. Just go to Settings > Printers and scanners > modify the printers one by one.

But you don't want to change the default paper size by hand every time you move between continents - especially if you have multiple printers and multiple computers. So in comes PowerShell!

Solution

Time needed: 5 minutes.

How to change printer paper size using PowerShell?

  1. Open PowerShell

    Should be easy enough. You should have 1 or more different PowerShell versions already installed on your machine, and any of them will do.

    Or, if you can't find it, get it following the directions here:
    Installing various versions of PowerShell

  2. Enumerate your printers and see their paper sizes

    Okay, easy enough - just run this in your PowerShell instance:

    Get-Printer | Get-PrintConfiguration | foreach-object { Write-Host $_.PrinterName: $_.PaperSize }

    You COULD also just omit everything after "| foreach-object..", and get a nicely formatted table - but you won't get the paper size that way.

    Anyway - you should get something like this:
    How to query all printers on your machine using PowerShell

  3. Update the paper size for your printer

    Okay - so now we know the printer names and their paper sizes. Let's set the offending printer straight somewhat like this:

    Set-PrintConfiguration -PrinterName "Brother HL-2030 (LPR)" -PaperSize "A4"

    Even if you get some access denied errors, it doesn't mean your change hasn't gone through. Jump to step 5 to verify!

  4. (OPTIONAL): Update the paper size for ALL of your printers

    You can also just set all of your printers to use the proper, German standard paper size. Let's just make this a one-liner:

    Get-Printer | Set-PrintConfiguration -PaperSize A4

  5. Verify your change was successful

    Just run the first thing again, and observe the output:

    Get-Printer | Get-PrintConfiguration | foreach-object { Write-Host $_.PrinterName: $_.PaperSize }

    Output from querying all of your printers using PowerShell.

That's it. The above should help you set the default paper size for one or more printers in Windows 10. Use it to switch it between A4 and Letter every week if you wish :)

Happy printing!

Postface

You might've noticed the cheeky tone of this article. Well done!

See, I'm sassing myself for spending 5 minutes figuring out the PowerShell to (partially) automate a 1-minute task... And THEN spending 10 minutes documenting it on my blog.

All for a task - printing - that I need to do roughly once a year. Today marked the second time I needed to print since I've moved back to Finland in 2019.

Oh well.

And as a side note - if you get these errors:

![Set-PrintConfiguration : Access was denied to the specified resource. At line:1 char:15

  • Get-Printer | Set-PrintConfiguration -PaperSize A4
  •           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  • CategoryInfo : PermissionDenied: (MSFT_PrinterConfiguration:ROOT/StandardCi...erConfiguration) [Set-Pri ntConfiguration], CimException
  • FullyQualifiedErrorId : HRESULT 0x80070005,Set-PrintConfiguration](images/9161-image-7-1024x342.png)

Set-PrintConfiguration : Access was denied to the specified resource.
At line:1 char:15
+ Get-Printer | Set-PrintConfiguration -PaperSize A4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (MSFT_PrinterConfiguration:ROOT/StandardCi...erConfiguration) [Set-PrintConfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070005,Set-PrintConfiguration

Have no fear! It's probably nothing at all. Just verify that the change was successful, and you should be good.

References

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.
JFFortier
2023-01-05 18:40:34)
This is an old post, but the command line to get the paper size return blank when the current paper size is a custom size form ?? That is what I'm trying to configure, for unknown reason, on network printer, advanced print default on the server and on the PC are set to that size. but that paper size is also set in the general>preference and sometime that config get reset to "letter". Since this custom paper size is set for our invoice on a dot matrix printer, when it goes to letter, all print get F*%$ up. Network users don't go near the printer until they scrap minimum 4-5 pages and they have to reprint. Any clue how to get it work with custom size ? Thanks
JFFortier
2023-01-05 18:55:21)
Ho! and that command line returns the paper size that is the default print settings (my system is not english, so it might not be the right wording) Printer property window Advanced tab>printing default. No, the current paper size is in the tab general>preference. In my case I need to change the one in the general tab, because this is where the current print document will pick it paper size. So even if the default (it should be for every new document!) is set for my custom size, it appears that WIn10 each time I reboot, doesn't set the paper size according to the default settings, but it selects the Letter size... out of nowhere !😣
Antti K. Koskela
2023-03-09 09:41:59
Hi mate, Hmm, interesting question - I have not used this with custom paper sizes at all, so unfortunately I have no real insights into that. In my experience, the default print size is the one that the printer should pick up when you're printing something (see the screenshot). In your case, this doesn't stick and the custom size is set differently? I'm suspecting some scheduled tasks or scripts or even a group policy might be in play here? I've had the printers reset to "Letter" before, but somehow, it's not been a problem with my current configuration. Did you ever figure out the reason why this happens for you?