Uninstall Using registry key failing on remote machines

I have been working on a script that will search the registry and uninstall software using the uninstall string vs using Get-WmiObject or GUID (as some software does not appear when I search using these solutions). My script completes without error but also without doing anything. I do not know where I am going wrong. I have exhausted myself googling this issue. Any help would be appreciated. My apologies for any obvious mistakes, I am still learning Powershell.

$targets = Get-Content “c:\targets.txt”

ForEach ($target in $targets){
$Test = Test-Connection -ComputerName $target -Count 1 -Quiet
If ( $test -eq $true ){

Invoke-Command -ComputerName $target -ScriptBlock {

$SoftVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -like “Google Chrome” } |
Select-Object -Property DisplayName, UninstallString

ForEach ($ver in $softVer) {

If ($ver.UninstallString) {

$uninst = $ver.UninstallString
& cmd /c $uninst /quiet /norestart}
}

}-AsJob
}
}

If you get absolutely nothing, it makes me think your Invoke-Command never runs, because -AsJob should at least list the job running even if it fails. See example 8 of Get-Help Invoke-Command. I don’t see anything glaring looking at your script, but a couple things I would recommend to help troubleshoot. First remove the Test-Connection loop and just put ALL the targets in your Invoke-Command. If the script cannot reach a target, you’ll get a non-terminating error, so at least you will know if the problem is it can’t actually reach your target. If that works and still nothing, then maybe none of your targets meet the criteria. If you know of one that should, then connect to an interactive session and try your logic a line at a time to see where it is failing. I’ve modified your code a little below to help get started.

$targets = Get-Content “c:\targets.txt”

Invoke-Command -ComputerName $targets -ScriptBlock {
    $paths = @("HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
               "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall")
    $SoftVer = Get-ChildItem -Path $paths  |
        Get-ItemProperty |
            Where-Object {$_.DisplayName -like “Google Chrome” } |
                Select-Object -Property DisplayName, UninstallString

    ForEach ($ver in $softVer) {
        If ($ver.UninstallString) {
            $uninst = $ver.UninstallString
            & cmd /c $uninst /quiet /norestart
        } #if
    } #foreach
} -AsJob