Skip to content

Instantly share code, notes, and snippets.

@Robert-LTH
Created May 1, 2019 22:48
Show Gist options
  • Save Robert-LTH/f405cc60ad57bf17b2d2b3795b13afda to your computer and use it in GitHub Desktop.
Save Robert-LTH/f405cc60ad57bf17b2d2b3795b13afda to your computer and use it in GitHub Desktop.
The order of WMI method parameters is a pain!
$MethodClass = [WmiClass]"\\COMPUTERNAME\NAMESPACE:CLASS"
$Method = "MethodName"
$InParams = $MethodClass.psbase.GetMethodParameters($Method)
$InParams.PSBase.properties | select Name,Value | format-Table
# Set the parameters with $InParams.Property = ""
# and invoke as follows
$Result = $MethodClass.InvokeMethod($Method, $InParams, $null)
$Result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment