Invoke Power Shell: The module 'reg query HKLM' could not be loaded. For more information, run 'Import-Module reg query HKLM'

Description

I’m getting the below error as “Invoke Power Shell: The module ‘reg query HKLM’ could not be loaded. For more information, run ‘Import-Module reg query HKLM’.” while executing the below query in power shell activity.

“reg query HKLM\Software\Policies\Microsoft\Edge\ExtensionInstallForcelist /v 1”

Can you please let me know what the issue is and how can i resolve this issue.

Link

Date

2024-04-15

Related UiPath products

Studio

@narasimhappa.devulacheruv,

Add this line of code before you use it’s commands.

Import-Module reg query HKLM

Thanks,
Ashok :slight_smile:

Hi Ashok,

Thank you for your response.

I tried it but still same issue. And my query is “reg query HKLM\Software\Policies\Microsoft\Edge\ExtensionInstallForcelist /v 1”

Which means do i add like “Import-Module reg query HKLM reg query HKLM\Software\Policies\Microsoft\Edge\ExtensionInstallForcelist /v 1” ?

@narasimhappa.devulacheruv,

I’m able to recreate the issue you are facing. It’s due to type of the command. It’s kind of script in it unlike of other commands like Get-Process etc.

Solution:
Just check the property IsScript like this and this will be resolved.

But you will have another error if you have kept property TypeArgument to default: System.Collections.ObjectModel.Collection<System.Management.Automation.PSObject>

Invoke Power Shell: Unable to cast object of type 'System.String' to type 'System.Collections.ObjectModel.Collection1[System.Management.Automation.PSObject]'.`

Solution to this, Change property TypeArgument to String and your Output variable should of of type:

System.Collections.ObjectModel.Collection<System.String>

Output:
image

Invoke Power Shell Properties
image

Thanks,
Ashok :slight_smile:

Hi Ashok,

Thanks for your help.

It worked now and issue got resolved.

@narasimhappa.devulacheruv,

That’s great!

Please mark my answer as solution so it will be helpful to other members as well.

Thanks,
Ashok :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.