When I run the following code i receive the message “cannot convert ‘System.Object[]’ to the type ‘System.String'”. How do i pass the event log list back to get-eventlog?
$EventLogList = Get-EventLog | Select-Object -ExpandProperty log
Get-evenlog -log $eventloglist
Get-EventLog : Cannot convert ‘System.Object[]’ to the type
‘System.String’ required by parameter ‘LogName’.
your help is appreciated
LogNameis a mandatory parameter toGet-EventLogand you have to supply it, unless you are trying to do a list with-list. Also, it expects a string and the second line is giving the error because you are passing in an array.Apart from that, it is also not clear what you are trying to do with the statements.
I suppose you want something like: