Posted this yesterday. Hope it just got overlooked. I really need help trying to figure out how to surpress the “save as” prompt when trying to print to PDF

I just want to print somefile.txt to somefile.pdf

Using this code (sry for bad formatting I’m on mobile )

$target = "C:temp" foreach($item in Get-ChildItem -Path $target -Filter *.txt) { $SaveAs = $item.name (Get-WmiObject -Class Win32_Printer -Filter"Name='Microsoft Print to PDF'").SetDefaultPrinter() Start-Process $target$SaveAs -Verb Print -ErrorAction Stop -WindowStyle Hidden } 

submitted by /u/KingBeef4
[link] [comments]

Leave a Reply