Share via

populating -instanceid dynamically

Jamie Woodford 21 Reputation points
2022-02-07T21:48:36.457+00:00

I have a .csv i am comparing againt the system eventlog I only want the macthing instanceid. i wrote..

get-eventlog -logname system -instanceID ${import-csv -path c:\example\example.csv -header instanceid}

I am new to PS and really shaking my head on this one

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

Rich Matheisen 48,116 Reputation points
2022-02-07T22:08:28.44+00:00

You could try something like this:

$InstanceIds = (import-csv -path c:\example\example.csv -header instanceid).instanceid |
                    Sort-Object -Unique
get-eventlog -logname system -instanceID $instanceids

Was this answer helpful?


1 additional answer

Sort by: Most helpful
  1. Jamie Woodford 21 Reputation points
    2022-02-08T01:28:34.277+00:00

    PLEASE HELP I only need this one line fixed without multiple other codes

    -InstanceId {import-csv -path C:\test\Appevt.csv -header instanceid}

    this is error

    Cannot bind parameter 'InstanceId'. Cannot convert the "@{instanceid=InstanceId}" value of type "CSV:Selected.System.Diagnostics.EventLogEntry" to type "System.Int64".

    I know i'm close but for whatever reason i can't make it work

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.