• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Powershell script runs but......

    Scheduled Pinned Locked Moved Solved
    FOG Problems
    4
    14
    769
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      BREIT
      last edited by

      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"
      
      do{
      $testpath = Test-Path -Path $file
      Start-Sleep -s 90
      }
      until($testpath -eq $true)
      
      Wayne WorkmanW J 2 Replies Last reply Reply Quote 0
      • J
        jflippen @BREIT
        last edited by

        @BREIT As promised, here is my setup for Office 2013.
        Snapin Pack settings:
        0_1543940813712_c5e9153a-c4d0-4f32-b235-b5879a0106b2-image.png

        Inside of the zipped Office 2013 folder:
        0_1543940980356_f805ae9a-5ad7-4720-a54c-6a6ef920a588-image.png

        And inside of updates folder:
        0_1543941043571_d1bcf0e9-3152-496b-95e9-dec7f9b7495f-image.png

        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.

        1 Reply Last reply Reply Quote 0
        • Wayne WorkmanW
          Wayne Workman @BREIT
          last edited by

          @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.

          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
          Daily Clean Installation Results:
          https://fogtesting.fogproject.us/
          FOG Reporting:
          https://fog-external-reporting-results.fogproject.us/

          B 1 Reply Last reply Reply Quote 0
          • J
            jflippen @BREIT
            last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • B
              BREIT @Wayne Workman
              last edited by

              @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.

              J 1 Reply Last reply Reply Quote 0
              • george1421G
                george1421 Moderator
                last edited by

                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.

                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                B 1 Reply Last reply Reply Quote 0
                • B
                  BREIT @george1421
                  last edited by

                  @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.

                  george1421G 1 Reply Last reply Reply Quote 0
                  • george1421G
                    george1421 Moderator @BREIT
                    last edited by

                    @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?

                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                    B 1 Reply Last reply Reply Quote 0
                    • B
                      BREIT @george1421
                      last edited by

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

                      george1421G 1 Reply Last reply Reply Quote 0
                      • george1421G
                        george1421 Moderator @BREIT
                        last edited by

                        @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.

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                        B 1 Reply Last reply Reply Quote 0
                        • B
                          BREIT @george1421
                          last edited by

                          @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.

                          J 1 Reply Last reply Reply Quote 0
                          • J
                            jflippen @BREIT
                            last edited by

                            @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:
                            https://stackoverflow.com/questions/1741490/how-to-tell-powershell-to-wait-for-each-command-to-end-before-starting-the-next

                            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.

                            B 1 Reply Last reply Reply Quote 0
                            • B
                              BREIT @jflippen
                              last edited by

                              @jflippen Thanks. I’ll look into this.

                              1 Reply Last reply Reply Quote 0
                              • J
                                jflippen @BREIT
                                last edited by

                                @BREIT As promised, here is my setup for Office 2013.
                                Snapin Pack settings:
                                0_1543940813712_c5e9153a-c4d0-4f32-b235-b5879a0106b2-image.png

                                Inside of the zipped Office 2013 folder:
                                0_1543940980356_f805ae9a-5ad7-4720-a54c-6a6ef920a588-image.png

                                And inside of updates folder:
                                0_1543941043571_d1bcf0e9-3152-496b-95e9-dec7f9b7495f-image.png

                                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.

                                1 Reply Last reply Reply Quote 0
                                • B
                                  BREIT
                                  last edited by BREIT

                                  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.

                                  1 Reply Last reply Reply Quote 0
                                  • 1 / 1
                                  • First post
                                    Last post

                                  209

                                  Online

                                  12.0k

                                  Users

                                  17.3k

                                  Topics

                                  155.2k

                                  Posts
                                  Copyright © 2012-2024 FOG Project