none
Windows Server 2016 Core - Sysprep FirstLogonCommands RRS feed

  • Question

  • I am trying to setup a Windows 2016 CORE server image. I have a PowerShell script that I would like to run once after sysprep. This works fine for server w/GUI - but for some reason with server core it will not run.

    <FirstLogonCommands>
                    <SynchronousCommand wcm:action="add">
                        <CommandLine>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden C:\Support\ServerConfigurationTool.ps1</CommandLine>
                        <Order>1</Order>
                    </SynchronousCommand>
    </FirstLogonCommands>

    Does anyone know if there is some caveat with core that prevents a run once command from running?  Or more specifically a Windows PowerShell script for the run once?  In my image, I have swapped the DOS prompt for the PS console as the default console that loads at login (not sure if that would matter, but just mentioning it just in case).

    Thanks

    NK

    Tuesday, June 27, 2017 7:45 PM

Answers

  • Looks like switching from cmd to PowerShell as the default shell breaks RunOnce, which I am guessing also breaks the sysprep FirstLogonCommands. There is a /runonce switch for the cmd shell that is not available, that I can tell, when using PowerShell.

    “/k runonce.exe /AleternateShellStartup”

    NK

    • Marked as answer by NJK-Work Wednesday, June 28, 2017 12:38 PM
    Wednesday, June 28, 2017 12:38 PM