Keith
Keith

Reputation: 791

Converting Invoke-WmiMethod command to Invoke-CimMethod command

I can't seem to reconfigure the below Invoke-WmiMethod command into a working Invoke-CimMethod command. This code is used to run SCCM client actions. An example of wanting to run the 'ApplicationDeploymentEvaluation' action is below.

What works:

Invoke-WmiMethod -Namespace ROOT\ccm -Class SMS_CLIENT -Name TriggerSchedule '{00000000-0000-0000-0000-000000000121}'

My attempt to reconfigure into an easier to read and replicate CimMethod, which does not work.

Invoke-CimMethod -Namespace ROOT\ccm -Class SMS_CLIENT -Name TriggerSchedule '{00000000-0000-0000-0000-000000000121}'

Error Received:

Invoke-CimMethod : Cannot bind parameter 'Arguments'. Cannot convert the "{00000000-0000-0000-0000-000000000121}" value of type "System.String" to type "System.Collections.IDictionary".
At line:1 char:106
+ ... CLIENT -Name TriggerSchedule '{00000000-0000-0000-0000-000000000121}'
+                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-CimMethod], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand

I am fairly certain the issue has to do with the -Name but everything I've attempted to change it to has generated an error.

Upvotes: 1

Views: 2257

Answers (1)

Larry Song
Larry Song

Reputation: 1144

Arguments is a dictionary

[[-Arguments] IDictionary]

Invoke-CimMethod -Namespace ROOT\ccm -Class SMS_CLIENT -Name TriggerSchedule -Arguments @{sScheduleID = '{00000000-0000-0000-0000-000000000121}'}

sScheduleID comes from

(Get-CimClass -Namespace ROOT\ccm -Class SMS_CLIENT).CimClassMethods

Upvotes: 2

Related Questions