Writing tabs to a file using PowerShell
powershell, syntax
Solution
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
Problem
I need to echo a series of elements of an array in PowerShell, but provide various delimiters between the elements, so I'm using; ``` Add-Content -Path $tempInputDir\testoutput.log -value ($($fields[0]) + " "+ $($fields[1]) + " " + $($fields[2]) + " " + $($fields[3]) + " "+ $($fields[15]) + " " + $($fields[17])) } ``` I need to be able to add tabs and space characters, as you can see from the code above I've just done this by physically adding tabs and spaces in between double quotes, but I'm sure this will cause problems down the line. What's the correct way to echo these characters to a file? I read somewhere that "'t" could be used, but that doesn't seem to work?