Uninstall Using registry key failing on remote machines

Welcome Forums General PowerShell Q&A Uninstall Using registry key failing on remote machines

Viewing 1 reply thread
  • Author
    Posts
    • #272584
      Participant
      Topics: 1
      Replies: 0
      Points: 12
      Rank: Member

      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
      }
      }

      • This topic was modified 1 week, 5 days ago by Noob_tech54.
    • #272650
      Participant
      Topics: 5
      Replies: 170
      Points: 656
      Helping Hand
      Rank: Major Contributor

      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.

       

      • This reply was modified 1 week, 5 days ago by Mike R..
      • This reply was modified 1 week, 5 days ago by grokkit.
Viewing 1 reply thread
  • You must be logged in to reply to this topic.