I am trying to create an nicely formatted Txt file (has to be Txt cannot be CSV) from a hashtable.
Here is the code that I have that creates the text file
$hashTable.GetEnumerator() | Sort-Object Name |
ForEach-Object {"{0} `t`t: {1} `t`t: {2} `t`t: {3} `t`t: {4}" -f $_.DisplayName,$_.EmployeeNo,$_.Email, $_.SamName,$_.Upn}|
Add-Content $textFilePath
As you can see - when someone is input into the Txt file with a long name it messes up the formatting because the tabs just get shifted along.
I'm looking for a solution that dynamically sets the width of the columns in a text file.