2013-02-27 201 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)"}