PowerShell: Per-user VMware Thinapp Registration Login Script

I'm not super familiar with ThinApping, but converted portions of this VMware login script at the request of a consultant.

I tried to automate the script a bit more than the one from VMware's blog. Their script required that you put in the path to each EXE. This script will find all exes within a directory and register them. So if your Microsoft Office 2013 has Word 2013.exe and Excel 2013.exe, you only have to add Microsoft Office 2013 to the hash table. They also required that you dig into the registry to find the key, but this script finds the key automatically.

This script requires just a couple changes:

  1. Your ThinApps directory that holds all of your captures.
  2. The location of thinreg.exe
  3. The ThinApp name + the group that needs it installed (ex.
    $thinappgroup.Add("Google Chrome 35", "Web Team"))

#########################################################################################

Per-user VMware Thinapp Registration

Author: Chrissy LeMaire

No guarantees, warranties, etc.

Conversion from: https://blogs.vmware.com/thinapp/2008/10/thinapp-thinreg.html

Be sure to name your ThinApp the same name as the directory you store it in

ex. Google Chrome 35 and \\fileserver\share\ThinApps\Google Chrome 35

#########################################################################################

Set your thinapp base folder location & thinreg.exe variables below

$baseappdir = "\\fileserver\share\ThinApps" $thinregexe = "\\fileserver\share\ThinApps\thinreg.exe"

Set the apps (usually folder names) and the AD group that has access

$thinappgroup = @{} $thinappgroup.Add("Google Chrome 35", "Web Team") $thinappgroup.Add("Notepad++", "Web Team") $thinappgroup.Add("Visual Studio 2013", "Web Team") $thinappgroup.Add("Microsoft Visio 2013", "Office VIP Users") $thinappgroup.Add("Microsoft Project 2013", "Program Managers") $thinappgroup.Add("LockOutStatus.exe", "Help Desk")

############## NOTHING MORE TO DO ##################################################

$groups = Get-ADPrincipalGroupMembership $env:username $baseappkey = "HKCU:\Software\Thinstall\ThinReg"

if (Test-Path $baseappkey) { foreach ($app in $thinappgroup.GetEnumerator()) { $appname = $app.Name $appnamereg = $app.Name + "_" $appgroup = $app.Value $appkey = (Get-ChildItem $baseappkey | Where-Object { $_.Name -like "*$appnamereg*" }).Name $apppath = "$baseappdir\$appname"

	if (Test-Path $apppath) { 
		$programs = Get-ChildItem $apppath | Where-Object { $\_.Name -like '\*.exe' }

		foreach ($program in $programs.name)
			{
			#if user is in group, register program, else remove program registration 
			$member = $groups | Where-Object { $\_.Name -eq $appgroup } 
			if ($member) {
					Write-Host "Installing $program"
					&$thinregexe "$apppath\\$program"
				}
			else 
				{
					if ($appkey -ne $null) {
						Write-Host "Removing $program"
						&$thinregexe /U "$apppath\\$program"
					}
				}
			}
	}
}

} else { Write-Host "Horizon Workstation not installed (registry key not found.)" }

Your registry key and directory structure should look something like this

 

Copyright 2003 -  Chrissy LeMaire. All Rights Reserved