Scripting Question

Post-Installation task wait issues (K2000)

01/20/2016 3936 views

I'm having issues with a post-installation task that Kace doesn't wait for to complete properly, it begins the next task that fails.
Some screenies below, first one in the begining, the other one shows the powershell window still being active and running a scripts, while Kace tries to install BGInfo which is the next task...



The details of the task that is causing the issue below:

Type: Application (the 2 files below zipped together)
Parameter: Remove-AllProvisionedAppxPackage.cmd
Content of cmd: Start /wait Powershell.exe -NoProfile -ExecutionPolicy ByPass -file Remove-AllProvisionedAppxPackage.ps1
Content of Remove-AllProvisionedAppxPackage.ps1: Get-appxprovisionedpackage –online | remove-appxprovisionedpackage –online

I've tried without "start /wait". I've tried running this with the command as a parameter instead, no difference. Please help me out.


Answer Summary:
1 Comment   [ + ] Show comment


  • You can start to play with PowerShell JOBS...
    You create a Job in the first script and you fire it.
    In the second script you check and wait for that job...
    It's better than wait a certain amount of time.
    It's perhaps a bit more complex but in my opinion possibly more robust.
    Kind regards,
    Marco - StockTrader
    • Thanks, I will save that url for the future :-)

Answer Chosen by the Author


I found the real cause for this problem and it's discussed here:


Answered 01/22/2016 by: szo850
Purple Belt

All Answers

You want to do a restart on the nuke the app command, the delete of the apps does not apply till a reboot on a lot of the  apps because they are in memory.  If you do not want to reboot use the ksleep command to cause a delay.

Answered 01/20/2016 by: SMal.tmcc
Red Belt

  • I'm only deleting provisioned apps from the image, not current user, no need for reboot. I can't get it to work properly with start /wait as you have above. Anyways, I've added "ksleep 60" so now it works (even though the script is executed twice for some strange reason. The second time it executes I get a UAC error, but because of the ksleep, the first script is allowed to finish. Wow...
  • When I run this powershell command as a BAT, it seems like some kind of character issue. It didnt say ...-Online. It said something like ...ÖoÖnline. That why powershell commands always fails for me when running them as BAT I guess.
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ