$pcname = $env:computerName
$reg = [microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine', $pcname)
$unkey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
$regkey = $reg.OpenSubKey($unkey)
$subkey = $regkey.GetSubKeyNames()

$programs = @()

foreach ($key in $subkey) {
  $thiskey = $unkey + '\' + $key
  $tsubkey = $reg.OpenSubKey($thiskey)
  $dname = $tsubkey.GetValue("DisplayName")
  if ($dname -ne '') {
    $programs += $dname
  }
}

if (Test-Path 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall') {
  $unkey = 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
  $regkey = $reg.OpenSubKey($unkey)
  $subkey = $regkey.GetSubKeyNames()

  foreach ($key in $subkey) {
    $thiskey = $unkey + '\' + $key
    $tsubkey = $reg.OpenSubKey($thiskey)
    $dname = $tsubkey.GetValue("DisplayName")
    if ($dname -ne '') {
      $programs += $dname
    }
  }
}

$in = 'Backup and Sync from Google', 'Dropbox', 'MEGAsync'
$out = @()
foreach ($i in $in) {
  if ($programs -contains $i) {
    $out += $i
  }
}

if ($out.Length -ge 2) {
  ''
  Write-Host -NoNewLine 'IMPORTANT: These programs should be immediately uninstalled -> '
  Write-Host -NoNewLine $out[0]
  for ($i = 1; $i -lt ($out.Length - 1); $i++) {
    Write-Host -NoNewLine (', ' + $out[$i])
  }
  Write-Host (', ' + $out[$out.Length - 1])
  ''
} else {
  if ($out.Length -eq 1) {
    ''
    Write-Host -NoNewLine 'IMPORTANT: This program should be immediately uninstalled -> '
    Write-Host $out[0]
    ''
  }
}
