views:

61

answers:

1

Hi All,

I'd like to know if this is possible Using Powershell 2.0 to traverse directory and print files on the client installed printer ?

i got the below powershell script it works great over the shared network drive but how to actually modify and use it to query the content of WebDav folders and then print only the .PDF file extension on the client side (not the server side)

Thanks.

Powershell to traverse the directory

function print-file($file) { begin { function internal-printfile($thefile) { if ($thefile -is [string]) {$filename = $thefile } else { if ($thefile.FullName -is [string] ) { $filename = $THEfile.FullName } } $start = new-object System.Diagnostics.ProcessStartInfo $filename $start.Verb = "print" }

if ($file -ne $null) { $filespecified = $true; internal-printfile $file } } process{if (!$filespecified) { write-Host process ; internal-printfile $_ } } }

dir *.pdf -r | print-file

A: 

The following command should do the trick - traverse all the files in the directory, get their content and send the content to the current printer. I tested it and it works fine:

Get-ChildItem . -filter *.* -recurse | get-content | out-printer

It takes all the files from the current folder.

David Pokluda
yes it works for normal directory that is already mapped to Windows Explorer.
Albert Widjaja
thanks for the reply man.
Albert Widjaja
here's another script that i use to traverse the directories:
Albert Widjaja