title: piping files to out-printer - powershell
body: <p>Got this script running. Nearly completed my mission to print attachments from it that land in a specific subfolder of outlook</p>
  
  <pre><code>    $OutputFolder = 'C:\tests';
  
  $outlook = New-Object -ComObject Outlook.Application; 
  $olFolderInbox = 6;
  $ns = $outlook.GetNameSpace("MAPI"); 
  $inbox = $ns.GetDefaultFolder($olFolderInbox);
  $inbox.Folders `
      | ? Name -eq 'colour' `
      | % Items `
      | % Attachments `
      | % {
          $OutputFileName = Join-Path -Path $OutputFolder -ChildPath $_.FileName;
          if (Test-Path $OutputFileName) {
              $FileDirectoryName = [System.IO.Path]::GetDirectoryName($OutputFileName);
              $FileNameWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($OutputFileName);
              $FileExtension = [System.IO.Path]::GetExtension($OutputFileName);
  
              for ($i = 2; Test-Path $OutputFileName; $i++) {
                  $OutputFileName = "{0} ({1}){2}" -f (Join-Path -Path $FileDirectoryName -ChildPath $FileNameWithoutExtension), $i, $FileExtension;
              }
          }
          Write-Host $OutputFileName;
          $_.SaveAsFile($OutputFileName)
      }
  
  Remove-Item -Path C:\tests\*.jpg
  
  Dir C:\tests\ | Out-Printer -name xerox-b8
  Remove-Item -Path C:\tests\*.*
  </code></pre>
  
  <p>when i try to pipe the objects to print i am getting XML printing out, or just the directory contents</p>
  
  <p>I have tried:</p>
  
  <pre><code>select-object (wrong)
  get-childitem (wrong)
  DIR C:\tests\*.* (only returns directory listing printout)
  </code></pre>
  
  <p>These either return a load of XML rubbish or just a directory listing, </p>
  
  <p>How can i pipe the contents of a folder to a printer using powershell, surely this can be done</p>