locked
Windows 7 x64 property of a registry value RRS feed

  • Question

  • Hello,

    I am using this script to detect differen Versions of which I want to delete.

    The script is normaly working, but now I am having a problem on my Windows 7 x64 test Computer.

    I want to catch the PSChild value of the current object but it is not work. I can't get any value.

    ((Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Publisher -like  $vApplicationVendor+"*" -and $_.DisplayName -like  $vApplicationName+"*"}).PSChildName)

    When I try it on another Computer with Windows 7 x64 then it is working.

    Both computers are fully patched and havinf PS 2.0.

    ################################################
    #Unsinstall Script                             #                            
    #by Florian zepter                             #
    #Version 1.0                                   #
    ################################################
    #Edit here:                                    #  
    #enter name and vendor (publisher) of the app  #
    #Put the names into ''                         #                              
    ################################################
        
        $vApplicationName = 'Brava!' 
        $vApplicationVendor = 'IGC'
        #$vApplicationVersion = '11.0.0'
        
    ################################################
    #no changes here!!!                            #
    #Uninstall function                            #
    ################################################
    
    #selection all the prducts where condition is suitable
    # get the msi product codes
        $vApplictaionDetect = @(
                                ((Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Publisher -like  $vApplicationVendor+"*" -and $_.DisplayName -like  $vApplicationName+"*"}).PSChildName)
                                ,
                                ((Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Publisher -like  $vApplicationVendor+"*"}).PSChildName)
                               )
    
        # remove software
        $vApplictaionDetect | ForEach-Object {if (!$_) {} else {Start-Process msiexec.exe -ArgumentList /x, $_, /qn -wait -passthru}}

    Tuesday, September 1, 2015 8:02 AM

Answers

  • To check a registry key use "Test-Path hklm:\Software\....\keyname"

    It is that easy.


    \_(ツ)_/

    • Marked as answer by Strahle_fz Thursday, September 10, 2015 6:39 AM
    Tuesday, September 8, 2015 3:27 PM
  • Hi Strahle,

    Try to run it as admin.

    also try it part by part if Get-ItemProperty is working

    Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | ft pschildname


    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    • Marked as answer by Strahle_fz Thursday, September 10, 2015 6:39 AM
    Wednesday, September 9, 2015 4:18 AM

All replies

  • Hi,

    I am comparing two equal variables but I am always getting "FALSE" when I do a proof:

    $vCondition1 = Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"{E95BCA9A-F9ED-48C7-AFB3-4053A0F1E02C}"

    $vCondition2 = Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"{E95BCA9A-F9ED-48C7-AFB3-4053A0F1E02C}"

    ($vCondition1 -eq $vCondition2)

    • Merged by Bill_Stewart Wednesday, September 9, 2015 12:25 PM Duplicate
    Tuesday, September 8, 2015 1:25 PM
  • Those are objects. Test on the properties.

    Tuesday, September 8, 2015 1:47 PM
  • Like mike said something like this

    $value1 = Get-ItemProperty 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{012D26C3-E12A-3BDA-8ECE-DF14E721A507}'
    $value2 = Get-ItemProperty 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{012D26C3-E12A-3BDA-8ECE-DF14E721A507}'
    
    if($value1.PSChildName -eq $value2.PSChildName)
    {
        "Yes - The ID's are same!"
    }
    else
    {
        "Nope - Match failed!"
    }

    In your code try like this

    $vCondition1 = Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"{E95BCA9A-F9ED-48C7-AFB3-4053A0F1E02C}"

    PS C:\> $vCondition1.GetType()

    IsPublic IsSerial Name                                     BaseType                                                                                                
    -------- -------- ----                                     --------                                                                                                
    True     False    PSCustomObject                           System.Object    


    Regards Chen V [MCTS SharePoint 2010]

    Tuesday, September 8, 2015 1:50 PM
  • Hi your script is working, thanks for that.

    But if I edit it for my script it does not work anymore:

    $value1 = Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Publisher -like "Lattice"+"*"}

    $value2 = Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Publisher -like "Lattice"+"*"}

    if($value1.PSChildName -eq $value2.PSChildName)

    {

        "Yes - The ID's are same!"

    }

    else

    {

        "Nope - Match failed!"

    }

    Tuesday, September 8, 2015 2:34 PM
  • What is the actual point of this exercise?

    Side note - why are you doing this: "Lattice"+"*"? Just do this 'Lattice*'


    Tuesday, September 8, 2015 2:41 PM
  • What are you actually trying to do? (What is the purpose of the script?)

    It looks like you are trying to determine if a software is installed or not.

    If that's what you're really trying to do, there's no need to reinvent the wheel.

    Windows IT Pro: Auditing 32-Bit and 64-Bit Applications with PowerShell


    -- Bill Stewart [Bill_Stewart]

    Tuesday, September 8, 2015 2:42 PM
  • at the end i have to proof if a registry key exits or not. I will do this in a Loop. Once the key is not theit any more, i have to end the Setup process.
    Tuesday, September 8, 2015 2:43 PM
  • What setup process? Why do you  need to do something in a loop?

    Remember, we can't see your screen.

    Tell what you want to do, not how you think you need to do it.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, September 8, 2015 2:45 PM
  • Ok I try to explain.

    I am having a Software installed (Name XVL Player / Publisher Lattice) in a lot of different Versions.

    On some Computers the software is installed a view times in different Versions.

    The Problem is that the Software does not have a silent uninstall Option.

    I grab the uninstall string and run it. once the Setup stands at the last window i have to Close that window.

    to be sure that the uninstallation was successful i check if the registry still Exits.

    if not, i stop the Setup process.

    Tuesday, September 8, 2015 2:50 PM
  • at the end i have to proof if a registry key exits or not. I will do this in a Loop. Once the key is not theit any more, i have to end the Setup process.

    So you're trying to do some sort of installation kludge?

    Do yourself a favor and stop right now. Fix the installation issue instead of doing whatever you're trying to do.


    Tuesday, September 8, 2015 2:50 PM
  • To check a registry key use "Test-Path hklm:\Software\....\keyname"

    It is that easy.


    \_(ツ)_/

    • Marked as answer by Strahle_fz Thursday, September 10, 2015 6:39 AM
    Tuesday, September 8, 2015 3:27 PM
  • Hi Strahle,

    Try to run it as admin.

    also try it part by part if Get-ItemProperty is working

    Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | ft pschildname


    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    • Marked as answer by Strahle_fz Thursday, September 10, 2015 6:39 AM
    Wednesday, September 9, 2015 4:18 AM
  • At the end it was very easy :-) Thanks at all:

       

       

    $vKey=((Get-ItemPropertyHKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*|Where-Object{$_.Publisher -like  $vApplicationVendor+"*"-and$_.DisplayName -like  "*"+$vApplicationName+"*"-and$_.UninstallString -like"*setup*"}).UninstallString) |Select-Object-First1


       

    do


        {

       

    Write-Host"loop"


       

    Write-Host"$vKey"


        }

       

    until(!(Test-PathHKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"$vkey"))

       

    Write-Host"END"


       

       

       

    Stop-Process-Namesetup


        }}

    Wednesday, September 9, 2015 1:31 PM
  • Great, you seem to have updated the code itself removing PSchildName.

    How about closing this up, by marking some answers.


    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    Thursday, September 10, 2015 4:26 AM