2012-07-11 75 views
1

我是Powerhell的新手。以下是我的要求:無法用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 @希塔爾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 
    } 


} 
+0

那麼,究竟是什麼問題?錯誤的輸出,一些錯誤,其他不良行爲?你想從樣本日誌中得到什麼樣的輸出結果? – vonPryz 2012-07-12 13:23:56

回答

0

嘗試是這樣的

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