Updated PowerShell script to loop through files for printing.

After finishing my script from the previous post I thought there has to be a better way to write this and reduce the lines of code. Not that 5 separate lines is a lot. But, if the list of items to print grew larger say to 15 documents, and was in different subdirectories then it might get complicated. So, I set about trying to find a way to use the ForEach-Object cmd. After some trial and error I have come up with this.
$Directory = “\\SVR1\DATA\Reports\Trading\”
Get-ChildItem -path $Directory -recurse -include *.pdf | ForEach-Object {Start-Process -FilePath $_.fullname -Verb Print -PassThru | %{sleep 10;$_} | kill }
Read More