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
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!
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.
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.
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
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.
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.
I have this almost working with Intune. Iāve just started using PSADT so Iām still learning my way around. The task is created and is set to run the Deploy-Application.exe from the IMECache but the IMECache clears after the deferment has been set. I understand this is how the cache works but is any ideas on how to work around this? Appreciate the help.