2013-02-27 131 views
0

我有這個腳本(下),我需要格式化輸出,以便它附加一個單詞+日期。你能幫我嗎?從powershell格式化輸出

Get-WmiObject -Class Win32_PerfFormattedData_W3SVC_WebService -ComputerName SERVERNAME | Where {$_.Name -eq "WEBURL"} | % {$_. CurrentConnections} 

我想輸出是類似於這個並追加,以便數據不會被覆蓋。

(從腳本輸出)+「連接的用戶」 +日期/時間

我所用,Export-Csv c:\scripts\log.txt -encoding "unicode" -force但並沒有給預期的效果。

回答

0

試試這個:

Get-WmiObject -Class Win32_PerfFormattedData_W3SVC_WebService -ComputerName SERVERNAME | 
    Where {$_.Name -eq "WEBURL"} | 
    Foreach {"$($_.CurrentConnections) connected users $(Get-Date)"}