$ObjDataSet2 = Invoke-SQLcmd -AbortOnError -Query $Query2 -Server $dbServer -Database $dbName -Username $dbUser -Password $dbPwd
$ObjDataSet2 | ConvertTo-Csv -Delimiter '|' -NoTypeInformation | out-file -Filepath $OutFile -Append
I am brand new to PowerShell, so don't know a lot, this may be a simple straight forward solution.
I am using above statements to get data from DB to create a pipe delimited file. Instead of pipe delimited I want to generate a fixed width file, I am not sure how to and what the syntax is. Below is the current output from above statements followed by expected fixed width output.
Current Output:
Product_Code|Prodct_ID|Product_Type|Cost
PM1234566|12345|Ellipse|10.13
PM12345672|1234609|Wheel|12.10
PM123456812|123470987|Rod|100.90
PM1234569|12348|Ellipse|14
========
Expected Output:
Product_Code Prodct_ID Product_Type Cost
PM1234566 12345 Ellipse 10.13
PM12345672 1234609 Wheel 12.10
PM123456812 123470987 Rod 100.90
PM1234569 12348 Ellipse 14
==========
Required Column Widths:
Product_Code: 1-13
Product_ID: 14-25
Product_Type: 26-41
Cost: 42-50
Thanks in advance for the help, formatting of fixed length is not coming out right when it gets converted, please look at the details below for width of each field.