Powershell script runs but......

  • So the script I built runs as expected but FOG reports it as being complete within 5 seconds of running. Even though Office 2013 hasn’t been installed yet. Any ideas?

    Start-Process 'Path.To.File' -ArgumentList '/adminfile .\FogOffice2013.MSP' 
    $file = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013"
    $testpath = Test-Path -Path $file
    Start-Sleep -s 90
    until($testpath -eq $true)

  • Thanks for everyones help. I decided to try it on an actual device and add the -Wait at the end and that worked. @jflippen your way worked as well. For what ever reason my VM was would both say complete right after the start of script. When I attempted to run it on a physical PC it worked without any issues and completed with the delays.

  • @BREIT As promised, here is my setup for Office 2013.
    Snapin Pack settings:

    Inside of the zipped Office 2013 folder:

    And inside of updates folder:

    Using this I have FOG download, install, and activate office for me even if I’m not on the domain yet.

    Let me know if you have questions.

  • @jflippen Thanks. I’ll look into this.

  • @BREIT Okay, so I am back at work today… and it looks like the fastest solution to your issue would be to get the -wait to work properly. I had a similar issue in a powershell script I made for deploying Lanschool.

    The answer for getting the Powershell script to stay open until the program installs (and thus, the FOG notification will be accurate) was the | Out-Null

    I got this answer from here:

    Below is a piece of my powershell script as an example:

    msiexec /i $teacher /qn ADVANCED_OPTIONS=1 CHANNEL=$channel ALLOW_DUMP_UPLOADS=0 | Out-Null

    I had promised you my Snapin Pack setup of Office 2013 as well, so I will post that as a 2nd comment to keep things cleaner.

  • @george1421 -Wait was one of the first things I tried. Same thing happened. I might try to make a batch script and try /wait for kicks and giggles. Curious to see if it would still happen or if it would work as expected. I might give that a go tomorrow.

  • Moderator

    @BREIT I know with batch scrips under certain conditions you need to start subprocesses with the start /wait <command_to_run> I just did a quick check and PS has a comparable switch.

    So I wonder what would happen if you changed your start process to this:

    Start-Process 'Path.To.File' -ArgumentList '/adminfile .\FogOffice2013.MSP' -Wait

    ref: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-6

    I agree the fog client should wait until the subprocess is done, the launch for the office install may be doing something strange that the fog client isn’t expecting. I think the devs should look at the code for the fog client, but the above flag may get you pass the issue until it can be researched a bit more.

  • @george1421 Yes you are following correctly. If I run the script manually it will run until that file shows up then exit as expected.

  • Moderator

    @BREIT Just so I understand it correctly. The script does execute and give the expected results in the end. The issue is that the FOG client is launching the process and then closing out saying that its done, and not launching and waiting until the install is finished.

    When you run the same PS script interactively the script will remain running until the application is installed?

  • @george1421 the path.to.file is set to the network location location of the the setup.exe that runs the .msp. I am running ours via powershell which is why .\ is there, it wouldn’t run without it. Like I said above the script runs just fine. Its just that fog comes back saying its completed almost immediately. Which it will complete just 4 or 5 mins later. I will however try your suggestion.

  • Moderator

    Looking at your script what is 'path.to.file' value set to?

    For our MDT deployment script the command is setup.exe /adminfile "Office_MSP_012118.MSP" for our 2016 install.

    I could also see '/adminfile .\FogOffice2013.MSP' also might be a problem. In that .\ might not be expanded correctly. You might want to use %~dp0\ there.

  • @Wayne-Workman I tried that and it failed. Which lead me down this rabbit hole. This process worked minus the quick complete message. Takes about 4 to 5 mins and it completes. All my other processes are running fine with the way you’ve mentioned.

    @jflippen I would appreciate that.

    This install is for Office 2013.

  • @BREIT I found it much easier to deploy office 2013 as a snapin pack. I just had to point it at the exe and have the setup-admin file in the updates folder along with other update files. Activates and everything! I won’t be at work tomorrow but I can show you screenshots of how I have my snapin setup when I get back if you like.

  • @BREIT Why are you running it as a process? Just call it normally and that should solve the waiting problem, and you can get rid of the loop.

Log in to reply