无法使用powershell脚本导出

时间:2012-07-11 10:51:04

标签: powershell export

我是PowerShell的新手。以下是我的要求:

读取csv日志文件并根据电子邮件字段,我必须查询并将结果导出到csv文件。

以下是一个示例日志文件:

  

EMAILID,日期,时间,CLIENT_IP,客户端主机,SERVER_IP,server_hostname,来源,event_id的       马努@ ionidea.com,05-24-2012,11:12:00,23.3.45.678,tytytyty,12.21.3.45,yuyuyuyuyu,hrertythghhdgfh,00928       RAM @ ionidea.com,06-05-2012,11:14:23,91.45.78.980,juqawessjj,16.51.5.93,pmbctr,ioyrhrtgdgdggdgjhjhj,00929       Sheetal说道@ ionidea.com,07-10-2012,11:12:00,10.0.87.369,yturbctyt,10.34.0.788,kokolioimdgf,brytifvnbty,00930

我正在使用以下脚本来执行此操作:

function saveAndRun(){

    $var_newJob = $window.FindName("txtbox_JobName").Text+".txt";
    write-host $var_newJob
    $varArray_emailIds =  ($window.FindName("txtbox_Email").Text).split(',');
    $var_fromDate = "'"+ $window.FindName("txtbox_FromDate").Text+"'";
    $var_toDate =  "'"+$window.FindName("txtbox_ToDate").Text+"'";
    $list="";
    ForEach($var_emailid in $varArray_emailIds){
    $emailid = "'"+$var_emailid+"'";
    ForEach-Object{

    Import-Csv D:\Manu\Xtract\Log\MSLogFile.txt | Where-Object {$_.emailid -eq $emailid -and ($_.date -ge $var_fromDate -and $_.date -le $var_toDate ) }

    } | Export-Csv -Path D:\Manu\Xtract\extract\$var_newJob
    } 


}

1 个答案:

答案 0 :(得分:0)

尝试这样的事情

Export-Csv -Path "D:\Manu\Xtract\extract\$var_newJob.csv"