-1

I am trying to get a PowerShell script to work to print out multiple documents to the default printer. Any ideas on what I can do to get this to work?

$files = Get-ChildItem -Filter "*.pdf"
foreach ($file in $files) {
    "c:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe" /t $file
}
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • If foxit reader is associated with `.pdf` files `Start-Process -FilePath $file –Verb Print` should do –  Jul 11 '17 at 07:26
  • Yeah that works but it doesn't work when running in a script while there is no active users logged in. My ultimate goal is to have a script run to print out files . – Jaken Gardner Jul 11 '17 at 13:02

1 Answers1

2

Use the parameter /p for printing to the default printer, use the call operator (&) for executing command paths in quotes.

Change this line:

"c:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe" /t $file

into this:

& "c:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe" /p $file
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328