Conditionally suppress Balloon Notifications

I am not using SCCM. I basically have Group policy execute two scripts:

  • One on machine startup to perform “system” deployment tasks - like installing software etc.
  • A second on user login that performs user profile tasks (desktop icons, HKCU registry settings etc)

Because I call the same set of PSAppDeploy files at every login I have had to implement a version system to prevent software installs happening again and again at evert restart.

For those interested see below. I basically track the $appScriptVersion in the registry and then call {Exit-Script 0} if there is no need to run the package again. Happy to hear if there is a better way of doing this.

What I have found is that when I call {Exit-Script 0} early in the script, I still get the balloon notification reporting a success. I want to suppress this balloon in cases when the module has already installed and I am skipping the deployment.

lines 103 added:

	## home baked version control system
$lastRunVersion = Get-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Unlock\$appVendor $appName\$appVersion\$DeploymentType" -value "ScriptVersion"			
If ($lastRunVersion -eq $appScriptVersion -and $appScriptVersion -ne '0') { Exit-Script 0 }

Then line 189 added:

	#Tracking information that the script was executed, home baked version control system
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock"
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName"
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName\$appVersion"
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName\$appVersion\$DeploymentType"
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName\$appVersion\$DeploymentType" -Name "ScriptVersion" -Value $appScriptVersion
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName\$appVersion\$DeploymentType" -Name "appDeployMainScriptDate" -Value $appDeployMainScriptDate
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName\$appVersion\$DeploymentType" -Name "currentDate" -Value $currentDate
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName\$appVersion\$DeploymentType" -Name "currentTime" -Value $currentTime
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName\$appVersion\$DeploymentType" -Name "MachineDomainController" -Value $MachineDomainController
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName\$appVersion\$DeploymentType" -Name "ProcessNTAccount" -Value $ProcessNTAccount
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\unlock\$appVendor $appName\$appVersion\$DeploymentType" -Name "SessionZero" -Value $SessionZero
1 Like

Insert this as desired to suppress or show balloon notifications:

[boolean]$configShowBalloonNotifications = $false
or…
[boolean]$configShowBalloonNotifications = $true

1 Like