我无法让PowerShell将日志名添加到csv

我无法让PowerShell将日志名添加到csv,csv,powershell,export-to-csv,invoke-command,Csv,Powershell,Export To Csv,Invoke Command,我无法让PowerShell将日志名添加到csv。我正在运行以下命令: Invoke-Command -ComputerName Server -Credential $cred -Authentication Default -ScriptBlock { Get-EventLog -LogName System -EntryType Error | Select-Object -Property PSComputerName, Site,TimeGenerated,

我无法让PowerShell将日志名添加到csv。我正在运行以下命令:

Invoke-Command -ComputerName Server -Credential $cred -Authentication Default -ScriptBlock { 
    Get-EventLog -LogName System -EntryType Error | 
        Select-Object -Property PSComputerName, Site,TimeGenerated, EventID, Message, Source, EntryType
} | Export-Csv -NoTypeInformation -Path C:/output.csv

任何帮助都将不胜感激

马特有正确的答案,经过测试,他的简单优雅的方法非常有效。非常感谢你,马特。非常感谢

|导出csv
应该在scriptblock中。如果我这样做了,它将存储在服务器上,我不希望这样,我需要它存储在本地。你只是想在每个条目的自己的列下添加“系统”吗?因为您只查看系统日志,所以不会假设这一点吗<代码>选择对象-属性PSComputerName、站点、TimeGenerated、EventID、消息、源、EntryType、@{name=“LogName”;表达式={“System”}您可以使用“|导出Csv-路径Microsoft.PowerShell.Core\FileSystem::\\servername\share\output.Csv”在scriptblock内部。我无法在我的工作站上用
| export csv
测试
Invoke命令,因为我们公司没有设置WinRM,但对我来说,这似乎令人困惑,因为如果不在scriptblock内部使用它,您没有任何东西可以导出到csv。