You can use ` (backtick) to "effectively" escape the CRLF allowing you to
span multiple lines for one command.
Brandon Shell
---------------
Blog:
http://www.bsonposh.com/
PSH Scripts Project:
www.codeplex.com/psobject
R> I have this function. It will probably wrap horribly but I hope you
R> get the idea.
R>
R> How can I comment it?
R> Nearly every spot I've tried to put any causes some kind of error.
R> function Get-Hard_Output ([string]$fname)
R> {(Execute-SQLcmd `
R> "select process_log_key,batch_key
R> from raser.dbo.process_log
R> where process_name = 'Importer.BulkInsertFileToWorkTable2'
R> and comment_desc like '%$($fname)%'" -q).tables.item(0).rows `
R> |%{(Execute-SQLcmd `
R> "select $($_.batch_key) as Batch_Key,
R> Process_Log_Key, Comment_Desc
R> from raser.dbo.process_log
R> where process_log_key > $($_.process_log_key)
R> and batch_key = $($_.batch_key)
R> and event_type_key = 10
R> and process_name = 'Exporter.WriteFileToWorkDir'
R> and process_log_key <
R> (select top 1 process_log_key from raser.dbo.process_log
R> where process_log_key > $($_.process_log_key)
R> and process_name in
R> ('Importer.BulkInsertFileToWorkTable2','Engine.Run')
R> order by process_log_key)
R> order by process_log_key" -q).tables.item(0).rows}`
R> |%{$t = $_;$t|select-object Batch_Key,Process_Log_Key,FileName `
R> |%{$_.FileName = split-path
R> ((($t.Comment_Desc).split())
R> [1]) -leaf;$_}}`
R> |%{$z = (Execute-SQLcmd `
R> "select Comment_Desc
R> from raser.dbo.process_log
R> where process_log_key > $($_.process_log_key)
R> and batch_key = $($_.batch_key)
R> and event_type_key = 12
R> and process_name = 'FileManager.ZipOutputFiles'
R> and comment_desc like '%$($_.FileName)%'
R> and process_log_key <
R> (select top 1 process_log_key from
R> raser.dbo.process_log
R> where process_log_key > $($_.process_log_key)
R> and process_name = 'Engine.Run'
R> order by process_log_key)
R> order by process_log_key" -q).tables.item(0).rows
R> if ($z.count -gt 0)
R> {$_.FileName = split-path
R> ((($z.item(0).Comment_Desc).split())
R> [3]) -leaf}
R> $_}
R> }