Here it’s my code :
Write-Host "Field 1 : " $variable1
Write-Host "Field 2 : " $variable2
Write-Host "Field 3 : " $variable3
Write-Host "Field 4 : " $variable4
I get an output like :
Field 1 : " $variable1
Field 2 : " $variable2
Field 3 : " $variable3
Field 4 : " $variable4
How can I align them?
Thanks
I think, based on his previous questions that field1,2,3 … are db fields names with variable length.
first solution, not very elegant but you can use the -f format operator to add some extra white-spaces to align your second column (bellow we use 40 characters minus the length of first column)
result
Second solution
If you create pscustom objects, then you can use all those fancy cmdlets such as format-table 🙂 :
Result :