Search code examples
csvpowershellexport-to-csvinvoke-command

i cannot get PowerShell to add the LogName to the csv


I cannot get PowerShell to add the LogName to the csv. I am running this command:

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

Any help would be greatly appreciated


Solution

  • Matt has the correct answer, after testing, his simple elegant method works perfectly. Thank you very much Matt. Much appreciated.