title: Is it possible to use a ternary operator inside a pipeline?
body: <p>I wish to send file and folder attributes to either a csv file or to the screen depending on the boolean value of $debug. I have tried to accomplish this by including a ternary operator in the end of the following pipeline:</p>
  
  <pre class="lang-bsh prettyprint-override"><code>Get-ChildItem $directory -Recurse -File |
      Select-Object @{name='Folder_Name';expression={$($_.directoryname)}},
                    @{name='File_type';expression={$($_.extension)}},
                    @{name='File_name';expression={$($_.name)}},
                    @{name='File_size_bytes';expression={$($_.length)}},
                    @{name='Creation_datetime';expression={$($_.creationtime)}},
                    @{name='Last_update_datetime';expression={$($_.lastwritetime)}},
                    @{name='Last_read_datetime';expression={$($_.lastaccesstime)}} |
                    (&amp;{if ($debug) {Write-Host} else {Export-Csv -path $outpath -NoTypeInformation -force -Delimiter ';'}})
  </code></pre>
  
  <p>Is this a bad approach, and which approach is recommended?</p>