PSADT.ToastNotification Extension

Bit confused with commenting out 579, here is what I have:

		if ($SessionZero) {
			$Privileges = [RunAsActiveUser.ProcessExtensions]::GetTokenPrivileges()["SeDelegateSessionUserImpersonatePrivilege"]
<#			if (-not $Privileges -or ($Privileges -band [RunAsActiveUser.PrivilegeAttributes]::Disabled)) {
				Write-Log -Message "Not running with correct privilege. You must run this script as system or have the 'SeDelegateSessionUserImpersonatePrivilege' token." -Severity 3 -Source ${CmdletName}
				if (-not $ContinueOnError) {
					if ($ExitOnProcessFailure) {
						Exit-Script -ExitCode 70604
					}
					throw "Not running with correct privilege. You must run this script as system or have the 'SeDelegateSessionUserImpersonatePrivilege' token."
				}
				elseif ($FallbackToOriginalFunctionOnError) {
					Invoke-Command -ScriptBlock $FallbackToOriginalFunction -NoNewScope
				}
				return
			}#>
			else {
				try {
					switch ($RunLevel) {
						"HighestAvailable" { $RunAsAdmin = $true }
						"LeastPrivilege" { $RunAsAdmin = $false }
					}

					if ($Wait) {
						$WaitTime = -1
						if (-not ($DisableFunctionLogging)) { Write-Log -Message "Wait parameter specified. The function will wait until process termination." -Source ${CmdletName} }
					}
					else {
						$WaitTime = 1
					}

					$Return = [RunAsActiveUser.ProcessExtensions]::StartProcessAsCurrentUser([NullString]::Value, "`"$($Path.FullName)`" $($ArgumentList)", $WorkingDirectory.ToString(), $ShowWindow, $WaitTime, $RunAsAdmin, $CaptureOutput)

					if ($CaptureOutput) {
						if (-not ($DisableFunctionLogging)) {
							if ($SecureArgumentList) {
								Write-Log -Message "CaptureOutput parameter specified, returning secured Standard Output string." -Source ${CmdletName}
							}
							else {
							 Write-Log -Message "CaptureOutput parameter specified, returned Standard Output string [$Return]." -Source ${CmdletName}
							}
						}
						return $Return
					}
				}
				catch {
					Write-Log -Message "Failed to execute process as currently logged on user.`r`n$(Resolve-Error)" -Severity 3 -Source ${CmdletName}
					if (-not $ContinueOnError) {
						if ($ExitOnProcessFailure) {
							Exit-Script -ExitCode 70605
						}
						throw "Failed to execute process as currently logged on user: $($_.Exception.Message)"
					}
					elseif ($FallbackToOriginalFunctionOnError) {
						Invoke-Command -ScriptBlock $FallbackToOriginalFunction -NoNewScope
					}
					return
				}
			}
		}

WOW I think this has fixed it.

Glad to know, donā€™t like the overall outcome since itā€™s letting pass some possible future errors.

Try a System and User deployment and let me know.

Appreciate the tenant access but currently have no more time to spend on this.

So will the extension not be getting any more updates? Just working out if I should be putting this into production.

At least not for now, If PSADT receive a major update Iā€™m quite sure it will have a Notification system.

You can try it and use it, the extension had a lot of time in developing and testing and itā€™s currently working fine in production (actually tested in a company with more than 20.000 devices).

1 Like

Hello, can you explain how you managed to get the toast notifications to work under Intune, I donā€™t understand for line 579. Thanks

i like this very much, we appreciate if you also give an example code with this.

or if any other member already have it please post it here.

Thank you

Can you share those ideas?

Hi itā€™s been a while, can remember all of them, but I started working on a module that autodetect if the process was called by serviceui and if not would wrap itā€¦ So at the end, no need to manually add serviceui handleling, it included exitcode and error plan B.

1 Like

@LFM8787 - Iā€™ve noticed that, after updating to the latest version (3.10.2) of PSADT, a couple things in this extension seem to have broken.

  1. Iā€™m not seeing error messages passed thru to the Toast Notifications
  2. Iā€™m also seeing {progressTitle} and {progressStatus} instead of their values, which looks like it is caused by PSADT changing some of the variable names or values that this extension relies on?

We were on 3.9.3 of PSADT which has a bug that the up-to-date version fixed and the bug is unfortunately present in my environment. If I revert PSADT to 3.9.3, these problems go away.

Any thoughts on what could be modified or examined to resolve these issues? I know youā€™ve mentioned you donā€™t have access to an SCCM/Intune environment, so please know any help is appreciated!

To help answer the question on running this extension while deploying via Intune:

Apps install from Intune via execution through the SYSTEM account/user which doesnā€™t have rights to draw into the userā€™s console/Notification session (one quick Google source on this). To get around this, execute the PSADT package with ServiceUI.exe:

ServiceUI.exe -Process:Explorer.exe Deploy-Application.exe ā€œDeploy-Application.ps1ā€ -DeploymentType ā€œInstallā€ -DeployMode ā€œInteractiveā€

This will allow the interactive components to be sent to the user, including the Toast Notification extension. No modifications to the code of Toast Notification seemed needed to enable this.

NOTE: You do not need the ServiceUI.exe part if you are deploying a per-user application (like one that operates from the appdata folder).

Hi, for sure they have changed something in the original functions, I will take a look and try to update the module, I canā€™t give you an ETA, cannot even test in lab environment.

Will try my best :slight_smile:

1 Like

I found no major changes in the latest version, nevertheless I refresh some functions and extended the compatibility from 3.8.4 to 3.10.2 included. Please replace your ToastNotificationExtension.ps1 file with the one below (expires in 7 days) for testing purposes:

(file removed, see post below)

Found the guilty commitā€¦ - Dot-source AppDeployToolkitExtensions.ps1 and other scriptblocks slightly earlier.

Since now theyā€™re parsing messages before the extensions I canā€™t embed the ToastNotification Messageā€¦

ā€¦ but, thereā€™s still an issue when running availability test, I created a bug in the official github, check this: [Bug] Unable to bypass $UseShellExecute when $WindowsStyle = ā€˜Hiddenā€™ in function Execute-Process #1058

It can fail sometimes due to that change, I will have to update the PSADT.RunAsActiveUser Extension later and if no triage for the bug sometimes you could see flashing powershell windowsā€¦

This is the new file with the modifications, still not uploaded to GitHub, please test:

I made some more changes, it was fun to revisit this huge project :slight_smile: so, please test this, I had to modify some functions on the fly because of the changes made to the original filesā€¦

Iā€™m 99% sure this will become the next version updated soon, please download and test this new files:

:heart: Thank you for the incredibly quick turnaround on this! :heart:

Iā€™ve downloaded and tested the changes. Hereā€™s what I saw:
:white_check_mark: I can now see the appropriate messaging when an app needs to be closed!
:white_check_mark: Error messages are being sent to the toast notification as expected!
:exclamation: I noticed Line 72 of the ToastNotificationExtension.PS1 has a typo and should be ā€œ$Parameterā€ instead of ā€œ$Parameteā€.
:exclamation: I also noticed that this latest version of the extension is minimizing all applications when triggered but didnā€™t see any XML settings to prevent that.

Other than these incredibly minor things, everything appears to be working great!

Thanks for the feedback, much appreciated :slight_smile:

Regarding the typo, I even forgot the catch idea, this is the complete block:

	catch {
		Write-Log -Message "The button [$Parameter] couldn't be translated, the default english string will be used." -Severity 2 -Source $ToastNotificationExtName
		$Parameter
	}

I was checking the minimize thing and I couldnā€™t find anything strange in the script, nothing was added that could trigger this options, I checked both versions of PSADT 3.9.3 and 3.10.2 and the logic behind this hasnā€™t changed at allā€¦

Function Show-InstallationWelcome {
	<#
	.SYNOPSIS
		Show a welcome dialog prompting the user with information about the installation and actions to be performed before the installation can begin.
    .
    .
    .
	.PARAMETER MinimizeWindows
		Specifies whether to minimize other windows when displaying prompt. Default: $true.

I couldnā€™t reproduce the behavior in mi computer, did you explicited ran the function with -MinimizeWindows $false because itā€™s enabled by defaultā€¦

I tried this command:

Show-InstallationWelcome -CloseApps 'notepad,mspaint' -AllowDeferCloseApps -DeferTimes 3 -PersistPrompt -MinimizeWindows $false -BlockExecution -CloseAppsCountdown 300

I did not and thatā€™s likely why the windows all minimized! I had overlooked that default so thank you for pointing that out!

We should be all set with these changes, which again thank you so much for completing!

For more information related to the usage or installation, follow the external link.

2024/10/02 - Updated to v1.1.4 :grinning:

  • On-thy-fly change to revert commit PSAppDeployToolkit/PSAppDeployToolkit@6d250d8 that causes the Test-ToastNotificationAvailability function to fail.
  • Moved from the old ResolveParameters scriptblock to the new Resolve-Parameters filter function.
  • Added MaxToastNotificationErrosThreshold for when a user is faster than timeouts/intervals defined in the config file.
  • Added extended warning to when extensions are loaded in wrong order.
  • Changed a lot of unnecessary [PSCustomObject] to faster hash-table type.
  • Reload full language strings from config files for backward compatibility.
  • Default to English if anything wrong happens in $xmlLoadLocalizedUIMessages scriptblock.
  • Errors handling for translated buttons.
  • Merged changes made to replaced functions.
  • Other minor logging changes and improvements.
1 Like