Reputation: 21
I have the script below that works just fine, but i need to use the pipe separator as a column separator, help :
$enddate = (Get-Date).tostring("yyyyMMdd")
$AttachmentPath6 = 'D:\PerfTeam_Queries\' + $enddate + '_Interfaces.csv'
$QueryFmt6= "SELECT NodeID,InterfaceID,InterfaceName,InterfaceType,InterfaceTypeDescription,InterfaceSpeed,InterfaceMTU,InBandwidth,OutBandwidth,FullName FROM Interfaces; "
Invoke-Sqlcmd -ServerInstance localhost -Database NetPerfMon -Query $QueryFmt6 | Export-CSV $AttachmentPath6
Upvotes: 1
Views: 2458
Reputation: 428
You need to use the parameter -s and then I would use quotes and put the pipe into those quotes i.e.
sqlcmd -S localhost -d NetPerfMon -Q $QueryFmt6 -s "|" -o $AttachmentPath6
As Per Matt's comment :
Invoke-Sqlcmd -ServerInstance localhost -Database NetPerfMon -Query $QueryFmt6 | Export-CSV -Delimiter '|' $AttachmentPath6
Upvotes: 1