Author Posts

August 6, 2017 at 12:01 am

I'm having a problem using this command.

Why does this work:

$csjob = get-wmiobject win32_computersystem -comp file-01 -asjob

...but this fails:

$csjob = get-eventlog system -comp file-01 -asjob

Get-EventLog : A parameter cannot be found that matches parameter name 'asjob'.
At line:1 char:44
+ $csjob = get-eventlog system -comp file-01 -asjob
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-EventLog], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetEventLogCommand

August 6, 2017 at 12:11 am

Because Get-EventLog doesn't have an -AsJob parameter, just as the error indicates.

Get-WmiObject's possession of -AsJob is actually something of a weird artifact. The replacement command, Get-CimInstance, doesn't.

You're meant to use Invoke-Command in all cases.

Invoke-Command -Script { Get-EventLog System -Comp file-01 } -AsJob