Jump to content
Testing123

Dealing with HKCU in Powershell

Recommended Posts

Hey everyone,

I've got a need to query HKCU for the currently-logged in user in Powershell.

I want to count the number of sub-keys under a particular reg key, so it's a task that CMD wouldn't be able to help with (to my knowledge at least), meaning I can't use Console Shell to run it as the user.

A fairly simply task to do in Powershell, but as far as I know there's not a way to run Powershell as a user in the same way we can use CMD with Console Shell. It would be much more simple/reliable if it could be run as the logged in user so it could query HKCU rather than trying to figure out the ID first.

Or is that the only way? Use Console Shell to figure out the ID and run it on HK_USERS?

Share this post


Link to post
Share on other sites

Any reason why you can't execute a console command which consists of

powershell.exe -command "myscript.ps1"

  • Thanks 1

Share this post


Link to post
Share on other sites
3 minutes ago, imurphy said:

Any reason why you can't execute a console command which consists of

powershell.exe -command "myscript.ps1"

Hahaha, well there's 3 hours of my life I'll never get back.

Yep, that'll do it. I need to pass back the result of the PS script into the Automate script, but there are plenty of options for doing that so it should be easy enough.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...