title: Manually removing all of LogMeIn
body: <p>I have a PowerShell script which removes LogMeIn (or any program where you search by name) from add/remove programs. </p>
  
  <p>This works perfectly however I would like to remove all instances of LMI, meaning any version that has been installed locally via plug-ins etc. </p>
  
  <p>The only way I thought of doing this was to delete the respective registry entries and app data - however querying the HKEY_USERS hive instead of HKCU hive is proving troublesome. </p>
  
  <p>Anyone had to do something similar, where they have a search term in registry they want to blitz off? 
  I have tried the mapping HKEY_USERS to a PS-Drive to query but just cant get the terminology right.</p>
  
  <pre><code>function ForceUninstall {
  Stop-Process -processname LMIGuardian*
  Stop-Process -processname LogMeIn*
  Stop-Process -processname LogMeInSystray*
  Stop-Process -processname ramaint*
  
  
  $null = New-PSDrive -PSProvider Registry -Name HKEY_USERS -Root HKEY_USERS
  cd HKEY_USERS:/
  $objects = get-childItem HKEY_USERS:\  -ErrorAction SilentlyContinue 
  
   foreach ($object in $objects){
   $testpath = "$($object.name)\Software\LogMeIn"
  
  $testpath =  $testpath -replace [Regex]::Escape("HKEY_USERS\"),'HKEY_USERS:\'
  $testpath2 = "$($object.name)\Software\LogMeIn Ignition"
  $testpath2 = $testpath2 -replace [Regex]::Escape("HKEY_USERS\"),'HKEY_USERS:\'
  If (test-path $testpath) {
   $PathsToDelete += $testpath 
   }
  
   If (test-path $testpath2) {
  $PathsToDelete += $testpath2 
   }
  
  }
    foreach ($Path in  $PathsToDelete){
   write-host "removing $path"
   (Get-ChildItem $Path).PsPath |Remove-Item -Recurse
   "Deleted registry key"
   }
  
  
   $LocalPaths = @("HKEY_LOCAL_MACHINE:\System\Current Control Set\Services\LMIInfo",
          "HKEY_LOCAL_MACHINE:\SOFTWARE\LogMeIn"
          "HKEY_LOCAL_MACHINE:\System\Current Control Set\Services\LMIMaint",
          "HKEY_LOCAL_MACHINE:\System\Current Control Set\Services\LMImirr",
          "HKEY_LOCAL_MACHINE:\System\Current Control Set\Services\LMIRfsClientNP",
          "HKEY_LOCAL_MACHINE:\System\Current Control Set\Services\LMIRfsDriver",
          "HKEY_LOCAL_MACHINE:\System\Current Control Set\Services\LogMeIn")
  
  
  
  $Location = New-PSDrive -PSProvider Registry -Name HKEY_LOCAL_MACHINE -Root HKEY_LOCAL_MACHINE
  cd HKEY_LOCAL_MACHINE:/
   foreach ($Path in  $LocalPaths){
   write-host "removing $path"
   (Get-ChildItem $Path).PsPath |Remove-Item -Recurse
   "Deleted registry key"
   }
  
   Remove-ItemProperty -Path "HKEY_LOCAL_MACHINE:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "LogMeIn GUI"
  write-host "removed LogMeIn GUI file"
  
   }
  </code></pre>