Improve the Support Experience with PSADK

I use Powershell Appdeployment Toolkit to package my application for SCCM. One thing i miss is, to see on the local Client which application is installed, when it was installed, from which source it was installed, and so one. Additional i want to repair applications on a very simple way without touching the SCCM Console. That was the reason for me to register every installed PSADK package in the local registry of the Computer and deregister it during an uninstallation of the application.

To reach this goal, i added the following two function to the AppDeployToolkitExtensions.ps1 file:

#region Register-Installation
Function Register-Installation {
<#
.SYNOPSIS
Saves state information about the installation in the registry of the target Computer.
.DESCRIPTION
Saves state information about the installation in the registry of the target Computer.
.EXAMPLE
Register-Installation
.NOTES
.LINK
http://wp.me/p61vmf-hR
#>
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'IsInstalled' -Value 1 -Type DWord
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'ScriptAppName' -Value "$appName" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'ScriptAppVendor' -Value "$appVendor" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'ScriptAppVersion' -Value "$appVersion" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'ScriptAppArch' -Value "$appArch" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'ScriptAppLanguage' -Value "$appLang" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'ScriptRevision' -Value "$appRevision" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'ScriptVersion' -Value "$appScriptVersion" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'ScriptDate' -Value "$appScriptDate" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'ScriptAuthor' -Value "$appScriptAuthor" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'PSADKVersion' -Value "$appDeployMainScriptVersion" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'InstallationDateTime' -Value "$currentDateTime" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'InstallationTimeZone' -Value "$currentTimeZoneBias" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'InstallationSource' -Value "$scriptParentPath" -Type String
$logFile = "{0}{1}" -f $logDirectory, $logName
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName" -Name 'LogFile' -Value "$logFile" -Type String
}
#endregion

#region Deregister-Installation
Function Deregister-Installation {
<#
.SYNOPSIS
Deletes state information about the installation in the registry of the target Computer.
.DESCRIPTION
Deletes state information about the installation in the registry of the target Computer.
.EXAMPLE
Deregister-Installation
.NOTES
.LINK
http://wp.me/p61vmf-hR
#>
Remove-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\PSADK\InstalledApps\$appName"
}
#endregion

After creating the functions in the Extension file you have to add the „Register-Installation“ call in the „Post-Installation“ and the „Deregister-Installation“ in the „Post-Uninstallatation“ section of your Installation packages.

If you run a script, you get the following installation details in your local registry:

Capture

This registry key is not just usable as Information-Base. If you use this key as Detection method for an successful Installation, you have a very easy to handle repair function. Just delete the registry-key to run an application again (be careful, this needs a well designed package as well 😉 ).

Capture

 

 

Advertisements

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s