Powershell script to find PC's that have dropbox installed

I have been using the get-installedapps.ps1 a ton for finding different apps that are installed on my domain. 

I am now trying to find any computers that has dropbox installed. Dropbox doesn't put it's unstall string in the normal place- it looks like it is in the HKEY_Users hive.

Does anyone know how I could scan my domain for any PC's that has dropbox?

 

Thanks in advance!

January 10th, 2012 11:46pm

there is a remote registry module (having MSDN problems right now) that will allow you check registry keys remotely. i believe it even has some Test-* cmdlets that would make it real easy to do.
Free Windows Admin Tool Kit Click here and download it now
January 11th, 2012 1:47am

Hi,

Yes, Dropbox put it in HK User hive. Localy you can get it like this:

$null = New-PSDrive -Name HKU   -PSProvider Registry -Root Registry::HKEY_USERS 

Get-ChildItem HKU:\ -ErrorAction SilentlyContinue | %{
 $key = $_.Name
 Get-ItemProperty "hku:\$key\software\microsoft\windows\currentversion\uninstall\*" -ErrorAction SilentlyContinue
}

But remotly it will something like that:

$Type = [Microsoft.Win32.RegistryHive]::Users
$ComputerName = "RemotePC"

$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Type, $ComputerName)
$subKeys = $regKey.GetSubKeyNames()

$subKeys | %{
 $key = "$_\software\microsoft\windows\currentversion\uninstall"

 Try
 {
  $regSubKey = $regKey.OpenSubKey($Key)
  $regSubKey.GetSubKeyNames()
 }
 Catch{}
}

January 11th, 2012 11:03am

Thank you very much for the quick reply. 

I am kinda new at this, and am unsure how to run it. How would I run this by using the (Get-content C:\listofcomputers.txt)?

 

Thanks again!

Free Windows Admin Tool Kit Click here and download it now
January 11th, 2012 6:06pm

Hi,

Not tested, it's only conception:

$Type = [Microsoft.Win32.RegistryHive]::Users

$ComputerNames = Get-content C:\listofcomputers.txt

foreach($ComputerName in $ComputerNames)
{

 $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Type, $ComputerName)
 $subKeys = $regKey.GetSubKeyNames()

 $subKeys | %{
  $key = "$_\software\microsoft\windows\currentversion\uninstall"

  Try
  {
   $regSubKey = $regKey.OpenSubKey($Key)
   $SubKeyNames = $regSubKey.GetSubKeyNames()
   if($SubKeyNames -match "Dropbox")
   {
     write-host "Computer $ComputerName contain dropbox"
   }

  }
  Catch{}
 }
}


January 11th, 2012 7:55pm

Thanks man! Getting closer. It is outputting that all computers contain dropbox (Even ones that do not)

 

Free Windows Admin Tool Kit Click here and download it now
January 11th, 2012 8:12pm

Then maybe clear status for each machine before check registry value: $SubKeyNames = $null

$Type = [Microsoft.Win32.RegistryHive]::Users

$ComputerNames = Get-content C:\listofcomputers.txt

foreach($ComputerName in $ComputerNames)
{
 $SubKeyNames = $null
 $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Type, $ComputerName)
 $subKeys = $regKey.GetSubKeyNames()

 $subKeys | %{
  $key = "$_\software\microsoft\windows\currentversion\uninstall"

  Try
  {
   $regSubKey = $regKey.OpenSubKey($Key)
   $SubKeyNames = $regSubKey.GetSubKeyNames()
   if($SubKeyNames -match "Dropbox")
   {
     write-host "Computer $ComputerName contain dropbox"
   }

  }
  Catch{}
 }
}

January 11th, 2012 8:42pm

Thanks Michal, I think I must be doing something wrong because it is still giving me the same results (all pc's are reporting that dropbox is installed. Even PC's that do not have it...as well as fake PC names)

I am going to keep trying to tweek it, but I think I may need to try a different route.

 

Thanks again!

 

Free Windows Admin Tool Kit Click here and download it now
January 12th, 2012 12:30am

Hi, Dunno, for me work fine. Last time try this:
$Type = [Microsoft.Win32.RegistryHive]::Users

$ComputerNames = Get-content C:\listofcomputers.txt
foreach($ComputerName in $ComputerNames)
{
	$Status = $null  #if machine is not available
	if(Test-Connection $ComputerName -Quiet)
	{
		$Status = $false
		$SubKeyNames = $null
		$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Type, $ComputerName)
		$subKeys = $regKey.GetSubKeyNames()

		$subKeys | %{
			$key = "$_\software\microsoft\windows\currentversion\uninstall"

			Try
			{
				$regSubKey = $regKey.OpenSubKey($Key)
				$SubKeyNames = $regSubKey.GetSubKeyNames()
				if($SubKeyNames -match "Dropbox")
				{
					$Status = $true
				}

			}
			Catch{}			
		}
	}
	
	$log = New-Object PSObject -Property @{
		ComputerName = $ComputerName
		Status = $Status
	}  
	
	$log	 
}

  • Marked as answer by Tiger Li Monday, January 16, 2012 1:26 AM
January 13th, 2012 10:26am

I found my problem I think- I should have mentions this...

In my environment, all of my machines are 64 bit. I am getting an errror with this bit of code:

$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Type, $ComputerName)

Should this be changed for x64 machines?

 

Thanks again, I really appreciate the help!

Free Windows Admin Tool Kit Click here and download it now
January 16th, 2012 9:56pm

This solved my task! I have been searching for days for a solution to get the validating DC for a specified users citrix session. This did the trick!

Thank you.

June 1st, 2012 8:56am

Hi,

I know this is old but I need this script.

Can you tell me how to run this and step by step what I need to do?

Thanks

Free Windows Admin Tool Kit Click here and download it now
February 6th, 2015 4:35pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics