Writing tabs to a file using PowerShell Writing tabs to a file using PowerShell powershell powershell

Writing tabs to a file using PowerShell


You can use `t for a tab character in a double quoted string. You can also simplify the above to:

"$($fields[0])   $($fields[1])   $($fields[2]) $($fields[3])  $($fields[15])  $($fields[17])" | Add-Content $tempInputDir\testoutput.log


To join the nominated fields together with tabs:

[string]::join("`t", (0..3,15,17 | % {$fields[$_]}))