Show-DeferPrompt

Full toolkit reworked with added custom defer prompt with selectable defer time units.

2 Likes

Sample Image:

2 Likes

Very Nice, Thank you for sharing, I did run into an issue with Defers not working though.
Turns out the script is trying to create a reg key here:

HKEY_LOCAL_MACHINE\SOFTWARE\Deferral\AppDefer

When I would run the script multiple times, the same deferral count would show. After looking at the console, it showed the “Deferral” key didn’t exist so it couldn’t create the “AppDefer” key.

I added these lines to the AppDeployToolkitExtensions.PS1 file to resolve the issue

$RegRoot = “HKLM:\SOFTWARE\Deferral”
New-Item -Path $RegRoot -ErrorAction SilentlyContinue

Here is where I added them:

if($ShowBalloon -eq $true) {
Show-BalloonTip -BalloonTipText “Installation deferred for $DeferTime $HrMin”
}
# Add new registry key and value for defer count
$RegRoot = "HKLM:\SOFTWARE\Deferral"
$RegPath = “HKLM:\SOFTWARE\Deferral\AppDefer”
$name = “DeferCount-$appName”
$newvalue = $DeferLimit
$type = “String”
$localvalue = Get-ItemProperty -Path $RegPath -Name $name -ErrorAction SilentlyContinue | > Select -ExpandProperty $name
# If the deferral reg key exists and it’s not equal to ‘0’, decrement the value by 1
if(($localvalue -ne $null) -and ($localvalue -ne 0)) {
Write-Host ‘found value’
$localvalue = $localvalue -1
Set-ItemProperty -Path $RegPath -Name $name -Value $localvalue
}
# If the If the deferral reg key is equal to ‘0’, start the standard installation script section
elseif($localvalue -eq 0) {}
# If the deferral reg key doesn’t exist, create it with the default value and decrement by 1
else {
New-Item -Path $RegRoot -ErrorAction SilentlyContinue
New-Item -Path $RegPath -ErrorAction SilentlyContinue
Set-ItemProperty -Path $RegPath -Name $name -Value $newvalue
$localvalue = (Get-ItemProperty -Path $RegPath -Name $name).$name
$localvalue = $localvalue -1
Set-ItemProperty -Path $RegPath -Name $name -Value $localvalue
}

Hopefully you can add this or something similar back to your source code or if someone else is running into this issue they can fix it using this code.

Also, Does your Defer Prompt have a countdown? I use this heavily for unattended machines and it would be a great feature to have. Thanks!

2 Likes

Good catch @king13p! I probably already had that reg key so I never ran into those issues. I’ll try and get it updated in the download soon.
I didn’t even think of the countdown option… Something to consider looking into for sure.

1 Like

Hi @FoldZan1,

A big thank you for sharing. I have been waiting for something like this but like @king13p would like to have a countdown so we can use the same package for both unattended lab install and staff updates so just registering a +1 for the countdown from me.

Cheers!

1 Like

@king13p I updated the share with this code.

1 Like

Great! Thanks.

One other question, I didn’t do a test of this for a standard user yet but it may be an issue. If a user selects defer, it creates a scheduled task for the user. Once the time hits and the task runs, UAC pops up trying to launch PowerShell. I’ll attempt to test it this week with a standard user but I believe you can run the scheduled task as NT AUTHORITY\SYSTEM to resolve this issue. The issue would be UAC will request a standard user to put in elevated credentials our users don’t have. If I have time today I’ll verify. Thanks

2 Likes

Hello All,

Thank for providing the updated package,

I am not able to produce defer while deploying this application via SCCM, on the other hand when i run this manually, the defer is coming up.

Please provide your valuable advice as i am stuck with this quite long.

Best Regards
Ravi Kumar

Hi, I am trying to use the tool provided by FoldZan1, however have run into an issue whereby after deferring the deployment for 30 mins it popped with a dialog box to allow PowerShell to run first before launching the Defer -Prompt Window.
Can someone advise how to fix the PowerShell popup.
Thks

It could have to do with your environment setup of UAC or the default PowerShell execution policy. Try changing the execution policy to bypass in the command in the scheduled task that the defer creates to run it again in 30 minutes.

In SCCM, are you creating the application to Run as User or System? You’d have to set it to run as User.

Hi FoldZan1 . Thanks for your quick reply. I was testing the app locally but will upload to sccm and try with the option ‘Install for user’ rather than ‘install for System’…

Unfortunately I’ve tested in sccm with the application set to ‘run as user’ and this prompts for admin credentials to open PowerShell. Can you advise how best to resolve the issue ?, as I would like to use the Defer-Prompt option provided. Thks

This good, but how do I get it to show a countdown and force close the apps that need closing so the process will auto continue? Show-deferprompt does not seem to accept the -ForceCloseAppsCountdown paramater.
The objective is for the process to continue if there isn’t a user present otherwise the without the countdown the process will just sit there.