title: Using PowerShell 2.0 to traverse directory and print files in the client?
body: <p>Using Powershell 2.0, is it possible to traverse directory and print files on the client-installed printer?</p>
  
  <p>I got the below PowerShell script. It works great over the shared network drive, but how do I 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)?</p>
  
  <p>PowerShell script to traverse the directory:</p>
  
  <pre><code>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"
              [System.Diagnostics.Process]::Start($start)
          }
  
          if ($file -ne $null) {
              $filespecified = $true;
              internal-printfile $file
          }
      }
      process {
          if (!$filespecified) {
              write-Host process ; internal-printfile $_
          }
      }
  }
  
  dir *.pdf -r | print-file
  </code></pre>