Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

System.Object[] as value in CSV

$
0
0

Hi all,

i have this:

Invoke-Command -ComputerName $i.computer -ScriptBlock { Get-Eventlog -LogName system   |  Where-Object {$_.EventID -eq "6008"}  }
                              
 if i write it out to a text file all values shows correct, but it shows me alot of other data i dont want. So if i only want the vlaue Machinename, Time, EventID and Message in a csv file 

example:

 $Result= Invoke-Command -ComputerName $i.computer -ScriptBlock { Get-Eventlog -LogName system   |
                Where-Object {$_.EventID -eq "6008"}  }
                              
                $objcsv = new-object PSObject
                $objcsv | add-member NoteProperty computer $result.machinename
                $objcsv | add-member NoteProperty Time $Result.Time
                $objcsv | add-member NoteProperty EventID $Result.EventID
                $objcsv | add-member NoteProperty Message $Result.Message
                $objcsv | export-csv "D:\Powershell\Get Event\outputfile_event.csv" -append -notypeinformation -Force
  
the output is :

"computer","Time","EventID","Message"
"System.Object[]","System.Object[]","System.Object[]","System.Object[]"

do i have to convert the value to a string ? and if so how ...

 

thanks..

 

 

 

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles