Powershell: Cannot convert 'System.Object[]' to the type 'System.String'

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


LogName is a mandatory parameter to Get-EventLog and 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:

get-eventlog -list | %{ get-eventlog -log $_.log }

Need Your Help

Virtual functions and detouring

c++ gcc virtual-functions detours

I've been programming with detours lately and all that comes with it. I have detoured a lot of different functions; thiscall, stdcall, cdecl, virtual functions etc. But there is one thing I haven't

Run Macro to Update Cells

excel vba excel-vba

I have quite a few cells that link to other worksheets/books, etc with standard excel formulae. However, is there a macro I can run that will only allow these cells to be updated when it is run? I'...