Hi All,

I have a PDF file that I want to print… easy enough:

Start-Process -FilePath “PathToPDF.PDF” –Verb Print

My problem is, I want to print 10 copies of this PDF file…
I understand I could put it in a for loop, but it takes too long. Is there a way I can tell PS to print 10 copies without using a loop? If I need to use the loop, is there a way to speed up the print process?

Thanks!
Steve

5 Spice ups

Maybe do a for-each loop and send the output to out-printer? If that doesn’t sound good someone on here will have the answer.

Hi!

You can use jobs instead of a loop, as jobs will create tasks that will run background and will be faster than a normal loop

4 Spice ups

Not sure you can do it within PowerShell without using a loop. You may be able to adjust your default settings for the printer though to accommodate.

Can you not just launch the PDF reader, open the file and click on File → Print → Copies: 10?

Thanks Nicolas! Exactly what I was looking for.

Here’s a script block for the community:
for ($i =0; $i -lt 10; $i++)
{
 Start-Job -Name “Print Job $i” -ScriptBlock{
Start-Process -FilePath “Blah” -Verb Print
}

}

Doing a Get-Job shows that all Background Jobs were completed.

3 Spice ups

At the end of your script you’ll want to clean up after yourself.

Get-Job | Wait-Job
Get-Job | Remove-Job -Force
4 Spice ups

Correct me if I’m wrong, but isn’t’ this still a loop?

1 Spice up

It is, but they’re all loading at the same time, instead of sequentially. Slower then just ONE run, but faster then 10 in sequence.

3 Spice ups

ISE just does not like this code block. Is it working for you?

It might have copied the quotes in as smart quotes. Replace those and it might work.