Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Read the registry with Powershell

Posted on 2014-12-04
6
378 Views
Last Modified: 2014-12-04
Hi,

is there any easy way to read and print (write-host) recourivly all sub-keys and value?

hklm-Software-AnySoftware

->
hklm-Software-Anysoftware-value1 = "hallo"
hklm-Software-Anysoftware-value2 = "another entry"
hklm-Software-Anysoftware-subkey1-value3 = "the3rdvalue"
hklm-Software-Anysoftware-subkey1-value4 = 5
hklm-Software-Anysoftware-subkey1-value5 = "the-last-entry"

something like this...

Thanks in advance

loosain
0
Comment
Question by:loosain
  • 2
  • 2
  • 2
6 Comments
 
LVL 24

Assisted Solution

by:NVIT
NVIT earned 100 total points
ID: 40481559
get-itemproperty -path hklm:\Software\Anysoftware -name value1
get-childitem -path hklm:\Software\Anysoftware -recurse | Format-Table -prop name
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 40481615
Great technet article on using powershell with the registry here
0
 

Author Comment

by:loosain
ID: 40481709
get-childitem comes close to that what i want to do.

get-childitem -path hklm:\Software\Anysoftware -recurse | Format-Table -prop name
shows me all the subkeys.

But i want the value store in the subkeys. With the first command (get-itemproperty) i can read them out.
But therfor i have to know which subkeys existing. How have i to pipe those two commands ?

Find out which subkeys existing -> for every subkey find out the value
And this recursively...

Thanks.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 37

Accepted Solution

by:
Neil Russell earned 400 total points
ID: 40481730
Try this out.

$path = "hklm:\Software\Microsoft"
Set-Location -Path $path
$Keys = get-ChildItem -path . -recurse
forEach($Key in $Keys)
  {
  forEach ($Value in $Key.GetValueNames()) {
    New-Object PSObject -Property @{
      Path = $Key.Name
      Name = $Value
      Value = $Key.GetValue($Value)
      Type = $Key.GetValueKind($Value)
    }
  }
}
0
 

Author Closing Comment

by:loosain
ID: 40481842
perfect. This worked.
0
 
LVL 24

Expert Comment

by:NVIT
ID: 40481848
Glad you got it working, loosain.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to count occurrences of each item in an array.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question