我有下面的脚本,它工作得很好,但我需要使用管道分隔符作为列分隔符,帮助:
$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发布于 2014-09-18 23:26:05
您需要使用参数-s,然后我将使用引号并将管道放入这些引号中,即
sqlcmd -S localhost -d NetPerfMon -Q $QueryFmt6 -s "|“-o $AttachmentPath6
根据Matt的评论:
Invoke-Sqlcmd导出本地主机-Database NetPerfMon -Query $QueryFmt6 | -ServerInstance -CSV -Delimiter '|‘$AttachmentPath6
https://stackoverflow.com/questions/25916219
复制相似问题