$in = "C:\in\" #Infolder/hotfolder $adobe='C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe' #Path to Acrobat $printername='psprinter' # Windows Printer Name $drivername='Xerox iGen 5 Press PS' # Windows Printer Driver Name $portname='c:\out\out.ps' # Port name $filter = "*.pdf" # Check only pdf files # Run when new pdf is created in $in $fsw = New-Object IO.FileSystemWatcher $in, $filter -Property @{IncludeSubdirectories = $false} $onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier Created -Action { Start-Sleep -s 30 # Wait 30 seconds $input_path = $Event.SourceEventArgs.FullPath # Full path to each new pdf $Name = $Event.SourceEventArgs.Name # Name of incoming pdf add-printerport -name "c:\out\$Name.eps" # Create new printer port based on file name set-printer -name "psprinter" -PortName "c:\out\$Name.ps" # Set printer port based on file name $arglist='/N /S /O /H /T "{0}" "{1}" "{2}" {3}' -f $input_path, $printername, $drivername, $portname # Argument list for printing each pdf Start-Process $adobe -ArgumentList $arglist # Print each pdf remove-printerport -name "c:*" # Remove local printer ports not in use }