none
Run a script in an MDT Task Sequence right before the first login... RRS feed

  • Question

  • Hey guys,

    I need to run a PowerShell script right before my MDT task sequence logs into Windows for the first time. I just cant remember at what step I need to add my "Run PowerShell Script" action. I think I need to put it somewhere under Postinstall or State Restore. Anybody know where this should go?

    Friday, August 24, 2018 2:29 PM

Answers

  • The MDT task sequence doesn't handle the login. The login is processed by the unattend.xml file. You can add the powershell command to your unattend.xml file. This will process before Windows logs in the first time, then restarts the MDT task sequence.

            <RunSynchronousCommand wcm:action="add">
              <Description>Powershell</Description>
              <Order>5</Order>
              <Path>powershell -executionpolicy bypass -file .\file.ps1</Path>
            </RunSynchronousCommand>

    Hey thanks for responding, but this is not what I am asking. Let me elaborate. I knew it was possible to run a script as a part of an MDT task sequence at some point before it hits the State Restore phase. The reason I knew this was because I actually did it a couple of years ago using a VBScript. It had just been a while and could not remember at what phase in the Task Sequence process I needed to place my run script action in order for it to succeed. I was hoping someone here on this forum had done something similar and could just refresh my memory if I asked. After I posted this and an answer was not quickly forthcoming I did a little digging through my old script repository and as luck would have it I kept a copy of that old VBScript and it was well commented by me. Here is the answer (copied and pasted from my script comments:

    Add a new "Run Command Line" option at the PostInstall phase just after "Copy Scripts"

    Again though, I appreciate your taking the time to respond. Thank you!

    • Edited by ZeusABJ Monday, August 27, 2018 2:21 PM
    • Marked as answer by ZeusABJ Monday, August 27, 2018 2:21 PM
    Monday, August 27, 2018 2:19 PM

All replies

  • The MDT task sequence doesn't handle the login. The login is processed by the unattend.xml file. You can add the powershell command to your unattend.xml file. This will process before Windows logs in the first time, then restarts the MDT task sequence.

            <RunSynchronousCommand wcm:action="add">
              <Description>Powershell</Description>
              <Order>5</Order>
              <Path>powershell -executionpolicy bypass -file .\file.ps1</Path>
            </RunSynchronousCommand>

    Sunday, August 26, 2018 10:36 PM
  • The MDT task sequence doesn't handle the login. The login is processed by the unattend.xml file. You can add the powershell command to your unattend.xml file. This will process before Windows logs in the first time, then restarts the MDT task sequence.

            <RunSynchronousCommand wcm:action="add">
              <Description>Powershell</Description>
              <Order>5</Order>
              <Path>powershell -executionpolicy bypass -file .\file.ps1</Path>
            </RunSynchronousCommand>

    Hey thanks for responding, but this is not what I am asking. Let me elaborate. I knew it was possible to run a script as a part of an MDT task sequence at some point before it hits the State Restore phase. The reason I knew this was because I actually did it a couple of years ago using a VBScript. It had just been a while and could not remember at what phase in the Task Sequence process I needed to place my run script action in order for it to succeed. I was hoping someone here on this forum had done something similar and could just refresh my memory if I asked. After I posted this and an answer was not quickly forthcoming I did a little digging through my old script repository and as luck would have it I kept a copy of that old VBScript and it was well commented by me. Here is the answer (copied and pasted from my script comments:

    Add a new "Run Command Line" option at the PostInstall phase just after "Copy Scripts"

    Again though, I appreciate your taking the time to respond. Thank you!

    • Edited by ZeusABJ Monday, August 27, 2018 2:21 PM
    • Marked as answer by ZeusABJ Monday, August 27, 2018 2:21 PM
    Monday, August 27, 2018 2:19 PM