-Iist not working within workflow

Hi,
I am trying to pull few registry value for 5k serves.with below command inside workflow:
Get-WmiObject -list -Namespace root\default | Where-Object {$_.Name -eq “StdRegProv”}
I am getting below error:
At E:\QR_Validation\Untitled4.ps1:13 char:16

  • … $reg = Get-WmiObject -List -Namespace root\default -PSComputerN …
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

Could not find a parameter named ‘List’. Supported parameters are: Amended, AppendOutput, Authority, Class, Debug, DirectRead, DisplayName, EnableAllPrivileges, ErrorAction, Filter, Impersonation,
InformationAction, Input, Locale, MergeErrorToOutput, Namespace, Property, PSActionRetryCount, PSActionRetryIntervalSec, PSActionRunningTimeoutSec, PSAllowRedirection, PSApplicationName, PSAuthentication,
PSAuthenticationLevel, PSCertificateThumbprint, PSCommandName, PSComputerName, PSConfigurationName, PSConnectionRetryCount, PSConnectionRetryIntervalSec, PSConnectionUri, PSCredential, PSDebug,
PSDisableSerialization, PSError, PSInformation, PSPersist, PSPort, PSProgress, PSProgressMessage, PSRemotingBehavior, PSRequiredModules, PSSessionOption, PSUseSsl, PSVerbose, PSWarning, Query, Result,
UseDefaultInput, Verbose, WarningAction.
+ CategoryInfo : ParserError: (:slight_smile: , ParseException
+ FullyQualifiedErrorId : CouldNotFindParameterName

You’ve hit one of the joys of workflows.
When you type
Get-WmiObject -list -Namespace root\default | Where-Object {$_.Name -eq “StdRegProv”}
in a Powershell console or run it in a script you’re running the Get-WmiObject and Where-Object CMDLETS.

When you use the same line in a PowerShell workflow you’re running POWERSHELL WORKFLOW ACTIVITIES. Think of an activity as a cmdlet with a .NET wrapper that may modify, add or remove parameters. In the case of Get-WmiObject the -List parameter has ben removed.

Depending on what you’re trying to achieve you may be able to wrap the code as an InlineScript

workflow test1 {
 
 Inlinescript {
   $reg = Get-WmiObject -list -Namespace root\default | Where-Object {$_.Name -eq "StdRegProv"}
   
 }
}

test1

It may be easier in the long run to use Invoke-WmiMethod or better still Invoke-CimMethod

workflow test2 {
 
[uint32]$hklm = 2147483650
$subkey = "SOFTWARE\Microsoft\Internet Explorer"
$value = "Version"

 Invoke-WmiMethod -Namespace root\cimv2 -Class StdRegprov -Name GetStringValue -ArgumentList $hklm, $subkey, $value
 
}

test2


workflow test3 {
 
[uint32]$hklm = 2147483650
$subkey = "SOFTWARE\Microsoft\Internet Explorer"
$value = "Version"

 Invoke-CimMethod -Namespace root\cimv2 -ClassName StdRegProv -MethodName GetSTRINGvalue -Arguments @{hDefKey=$hklm; sSubKeyName=$subkey; sValueName=$value}
 
}

test3