$Directory = "\\servershare\PDLabels"

Get-ChildItem -path $Directory -recurse -include *.pdf | ForEach-Object {Start-Process -FilePath $_.fullname -Verb Print -PassThru | %{sleep 10;$_} | kill}

Does anyone know how to delete the file after it prints? I have tried everything and it works if a manually run it but as soon as I put into a scheduled task it deletes the files before the next print.

I was thinking another scheduled task with remove item but it got clunky and the timing was way off. I just want to print the pdf, then delete it.

5 Spice ups

start-process has a ‘-wait’ property.

why don’t you try to start the print with wait and then a delete?

e.g.

$Directory = "\\servershare\PDLabels"

Get-ChildItem -path $Directory -recurse -include *.pdf | 
ForEach-Object {
    Start-Process -FilePath $_.fullname -Verb Print -Wait
    remove-item $_.FullName -verbose -Force
}
2 Spice ups

That works with one caveat. I cant figure out where to put kill to shutdown adobe. Send you a coffee!!

maybe like so

$Directory = "\\servershare\PDLabels"

Get-ChildItem -path $Directory -recurse -include *.pdf | 
ForEach-Object {
    Start-Process -FilePath $_.fullname -Verb Print -Wait
    get-process *adobe* | stop-process -force
    remove-item $_.FullName -verbose -Force
}
1 Spice up