Show-DeferPrompt

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

1 Like

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