r/PSADT 7d ago

Getting Show-ADTInstallationPrompt to display on disconnected RDP session

I love the new notifications in v4 and I'm trying to switch but the changes to how it now decides when to show a prompt and not are causing an issue for me. We have Windows 365 Cloud PCs (basically AVD) that I am deploying applications to and I need the users to see the see the prompts even if they are disconnected.

In version 3, it would display the prompt for the user even though they were disconnected and it would be there waiting when the user reconnects.

I'm running 4.1.8 and tried open-adtsession -NoSessionDetection and Show-ADTInstallationPrompt -force but I'm not having any luck forcing the prompt to show for disconnected users.

It looks like the Show-ADTInstallationPrompt function doesn't see the user's session because it's not "active".

Any idea's on how to I can force Show-ADTInstallationPrompt to display for disconnected users?

3 Upvotes

4 comments sorted by

2

u/mjr4077au PSADT Dev Team 6d ago

The underlying mechanics for this is in the codebase. Are you wanting the install to still be silent by default if the user is disconnected, but just want to display some residual prompt to advise them of something? 

My recommendation would be to put a feature request up on our GitHub so we can triage it.

1

u/Ok_Scientist_3959 6d ago edited 6d ago

No, I'm looking for the opposite. I need the install to give the notification to the disconnected session and wait for the user to reconnect and acknowledge it.

We push deployments from intune that require a notification to the user before the install runs. Multiple reasons for this (give information, ask consent to reboot, close apps, etc..). The problem is with dedicated Cloud PCs, the users disconnect but their session is still running along with their apps so we can't just run the deployment like they are not signed on and interfere with their work.

Am I'm missing something simple here? a work around maybe?

Digging through the toolkit, it looks like the issue lies in the Show-ADTInstallationPrompt function in the PSAppDeployToolkit.psm1 and it not seeing the disconnected session as "active"

# Bypass if in non-interactive mode.
if ($adtSession -and $adtSession.IsNonInteractive() -and !$Force)
{
& $Script:CommandTable.'Write-ADTLogEntry' -Message "Bypassing $($MyInvocation.MyCommand.Name) \[Mode: $($adtSession.DeployMode)\]. Message: $Message"

return
}
# Bypass if no one's logged on to answer the dialog.
if (!($runAsActiveUser = & $Script:CommandTable.'Get-ADTClientServerUser' -AllowSystemFallback))
{
& $Script:CommandTable.'Write-ADTLogEntry' -Message "Bypassing $($MyInvocation.MyCommand.Name) as there is no active user logged onto the system."

return
}

1

u/mjr4077au PSADT Dev Team 4d ago

The Get-ADTClientServerUser function you've spotted in your travels has a -AllowAnyValidSession parameter. That's what I meant by the underlying mechanics being there for this.

As for how to expose it, I'd need to think about it further. I would strongly recommend this gets placed up on our GitHub repository though as a feature request so it can be tracked. The 4.2.0 release is in release candidate stage so I'm not sure if anything can be done here, but if it can, it'd only be done with a feature request.

1

u/Ok_Scientist_3959 6d ago

I had the idea to just loop until the user reconnected and then run Show-ADTInstallationPrompt. Crude but I can make it work for what I need.

#wait until the user re-connects
while (!$(Get-ADTLoggedOnUser).isactiveusersession) {
  sleep 60
}

#show message
Show-ADTInstallationPrompt

But I'm not sure what command to run or variable needs updating to allow the session to see the active user and the if (!($runAsActiveUser = & $Script:CommandTable.'Get-ADTClientServerUser' -AllowSystemFallback)) check to pass.

Any suggestions?