Powershell 和 logparser 参数 [英] Powershell and logparser arguments

查看:25
本文介绍了Powershell 和 logparser 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从 powershell 运行一些 logparser 命令,但我在正确传递参数时遇到问题,这是我脚本中的 excert;

d:\scripting\smtplogs\logparser\logparser.exe "SELECT TOP 50 Receiver, COUNT() INTO %TMPOutput%\TopReceiversNDRALL.gif FROM %TempDir%\PostAll.log WHERE Sender LIKE '<>' AND Receiver NOT LIKE '%%go-fmtopper%%' GROUP BY Receiver ORDER BY COUNT() DESC" -i:TSV -iSeparator:space -headerRow:OFF -iHeaderFile:"header3.tsv" -lineFilter:+10."-o:CHART -chartType:ColumnClustered -config:MyScript.js -chartTitle:NULL 消息的接收器全部用于 %DateGraph%"

我已经阅读了大量关于封装参数的内容,但似乎无法弄清楚如何使其工作!

如果您能提供任何帮助,我们将不胜感激.

谢谢

解决方案

对于复杂的字符串参数,尝试使用 powershell 传递参数 here-strings 这样您就不必担心转义单引号/双引号

UPDATE1:我无法让格式化工作,所以这是屏幕截图.

UPDATE2:我终于能够格式化代码了.

<前>d:\scripting\smtplogs\logparser\logparser.exe @"选择前 50 个接收器,计数()INTO %TMPOutput%\TopReceiversNDRALL.gif从 %TempDir%\PostAll.log发件人喜欢的地方 ''AND Receiver NOT LIKE '%%go-fmtopper%%'按接收方分组按计数排序() DESC"-i:TSV-iSeparator:空格-headerRow:OFF-iHeaderFile:"header3.tsv"-lineFilter:+10."-o:图表-chartType:ColumnClustered-config:MyScript.js-chartTitle:" NULL 消息的接收器 ALL 用于 %DateGraph%"@

确保在此处的字符串名称 @""@ 之间添加一个新行.

Im trying to run some logparser commands from powershell but Im having issues with passing the arguments across correctly, heres the excert from my script;

d:\scripting\smtplogs\logparser\logparser.exe "SELECT TOP 50 Receiver, COUNT() INTO %TMPOutput%\TopReceiversNDRALL.gif FROM %TempDir%\PostAll.log WHERE Sender LIKE '<>' AND Receiver NOT LIKE '%%go-fmtopper%%' GROUP BY Receiver ORDER BY COUNT() DESC" -i:TSV -iSeparator:space -headerRow:OFF -iHeaderFile:"header3.tsv" -lineFilter:"+10." -o:CHART -chartType:ColumnClustered -config:MyScript.js -chartTitle:"Receivers for NULL messages ALL for %DateGraph%"

Ive read loads about encapsulating arguments but cant seem to figure out how to make this work!

Any help that you guys could provide would be very appreciated.

Thanks

解决方案

For a complex string parameter, try to pass the argument using powershell here-strings so that you wouldn't have to worry about escaping single/double quotes

UPDATE1: I couldn't get the fomratting working so here is the screenshot.

UPDATE2: I was able to format the code finally.

d:\scripting\smtplogs\logparser\logparser.exe @"
SELECT TOP 50 Receiver, COUNT() 
INTO %TMPOutput%\TopReceiversNDRALL.gif 
FROM %TempDir%\PostAll.log 
WHERE Sender LIKE '' 
      AND Receiver NOT LIKE '%%go-fmtopper%%' 
GROUP BY Receiver 
ORDER BY COUNT() DESC" 
-i:TSV 
-iSeparator:space 
-headerRow:OFF 
-iHeaderFile:"header3.tsv" 
-lineFilter:"+10." 
-o:CHART 
-chartType:ColumnClustered 
-config:MyScript.js 
-chartTitle:"Receivers for NULL messages ALL for %DateGraph%
"@

Make sure that you add a new line between the here-string monikers @" and "@.

这篇关于Powershell 和 logparser 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆