registry keys in variables

Welcome Forums General PowerShell Q&A registry keys in variables

This topic contains 2 replies, has 2 voices, and was last updated by

6 months, 3 weeks ago.

  • Author
  • #103553

    Points: 0
    Rank: Member


    i´m trying to read some keys from the registry, save them in a variable for using them.
    (scanning a complete network for installed Programs, this is only a small part of it)

    $varName = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | select Name;
    foreach ($Prog in $Varname){
        get-childitem $Prog | select Name

    for me as a PS beginner i can´t imagine why there is ny working path in front of the $Prog when using it in foreach f.e. c:\Windows\system32\@{Name=hklm.....

    I hope you can help me


  • #103555

    Points: 399
    Helping Hand
    Rank: Contributor

    If you do not specify a complete path Powershell uses the current directory to complete the path. If I got you right you#re looking for something like this:

    $varName = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ 
    foreach ($Prog in $Varname){
        Get-ItemProperty $Prog.PSPath

    or this

    Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*\
  • #103567

    Points: 0
    Rank: Member

    The one solution with $Prog.PSPath is the one i was looking for 🙂 thx
    I need to know all installed software its display name and version nummer and now i can get it

The topic ‘registry keys in variables’ is closed to new replies.