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
}
}
}
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).
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.
@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.
Iām not seeing error messages passed thru to the Toast Notifications
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:
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.
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:
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 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:
Thank you for the incredibly quick turnaround on this!
Iāve downloaded and tested the changes. Hereās what I saw:
I can now see the appropriate messaging when an app needs to be closed!
Error messages are being sent to the toast notification as expected!
I noticed Line 72 of the ToastNotificationExtension.PS1 has a typo and should be ā$Parameterā instead of ā$Parameteā. 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!
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ā¦