FirstLogonCommands in unattend.xml do not work


  1. Posts : 3
    10
       #1

    FirstLogonCommands in unattend.xml do not work


    Hello. I have created an unattend answer file to be used with a windows 10 image and I am experiencing an issue. I have placed a powershell command under the "FirstLogonCommands" but it is never run. Here is my answer file:

    HTML Code:
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
    	<settings pass="oobeSystem">
    		
    		<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    			<InputLocale>en-US</InputLocale>
    			<SystemLocale>en-US</SystemLocale>
    			<UILanguage>en-US</UILanguage>
    			<UILanguageFallback>en-US</UILanguageFallback>
    			<UserLocale>en-US</UserLocale>
    		</component>
    		
    		<component name="Microsoft-Windows-International-Core" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    			<InputLocale>en-US</InputLocale>
    			<SystemLocale>en-US</SystemLocale>
    			<UILanguage>en-US</UILanguage>
    			<UILanguageFallback>en-US</UILanguageFallback>
    			<UserLocale>en-US</UserLocale>
    		</component>
    		
    		<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    			<OOBE>
    				<HideEULAPage>true</HideEULAPage>
    				<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
    				<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
    				<ProtectYourPC>1</ProtectYourPC>
    				<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
    			</OOBE>
    			<FirstLogonCommands>
    				<SynchronousCommand wcm:action="add">
    					<CommandLine>Powershell -Command "Set-ExecutionPolicy RemoteSigned -Force; $LanguageList = Get-WinUserLanguageList; $LanguageList.Add('el-GR'); Set-WinUserLanguageList $LanguageList -Force; tzutil /s 'GTB Standard Time'; set-culture en-GB; Powercfg /Change standby-timeout-ac 0; Powercfg /Change standby-timeout-dc 0;"</CommandLine>
    					<Description>Add Greek language to input languages, Set time zone to UTC+02:00, Set region to en-GB (User Locale), Change Sleep settings to "Never"</Description>
    					<Order>1</Order>
    					<RequiresUserInput>false</RequiresUserInput>
    				</SynchronousCommand>
    			</FirstLogonCommands>
    		</component>
    		
    		<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    			<OOBE>
    				<HideEULAPage>true</HideEULAPage>
    				<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
    				<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
    				<ProtectYourPC>1</ProtectYourPC>
    				<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
    			</OOBE>
    			<FirstLogonCommands>
    				<SynchronousCommand wcm:action="add">
    					<CommandLine>Powershell -Command "Set-ExecutionPolicy RemoteSigned -Force; $LanguageList = Get-WinUserLanguageList; $LanguageList.Add('el-GR'); Set-WinUserLanguageList $LanguageList -Force; tzutil /s 'GTB Standard Time'; set-culture en-GB; Powercfg /Change standby-timeout-ac 0; Powercfg /Change standby-timeout-dc 0;"</CommandLine>
    					<Description>Add Greek language to input languages, Set time zone to UTC+02:00, Set region to en-GB (User Locale), Change Sleep settings to "Never"</Description>
    					<Order>1</Order>
    					<RequiresUserInput>false</RequiresUserInput>
    				</SynchronousCommand>
    			</FirstLogonCommands>
    		</component>
    		
    	</settings>
    </unattend>
    What bothers me is, that when I manually run that command after OOBE finishes, the command is executed perfectly.
    I have also tried replacing that command with:

    1. cmd.exe /c powershell -command "COMMANDS"
    2. powershell .exe COMMANDS (without quotes)
    3. %WINDIR%\System32\cmd.exe /c powershell -Command "COMMANDS"
    4. %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe COMMANDS (without quotes)

    Nothing seems to work and I cannot understand why. All the other sections in the answer file are processed correctly without any issues. Also, I am trying to avoid creating a batch file that has the script inside, since I only want to use just one answer file to execute a simple powershell command.

    Any help would be highly appreciated. Thanks.
      My Computer


  2. Posts : 4,187
    Windows 11 Pro, 22H2
       #2

    Welcome to TenForums! Have you tried placing that section in the autounattend.xml rather than the unattend.xml answer file?
      My Computers


  3. Posts : 3
    10
    Thread Starter
       #3

    hsehestedt said:
    Welcome to TenForums! Have you tried placing that section in the autounattend.xml rather than the unattend.xml answer file?
    Hello :) ! No, I haven't tried that. I thought autounattend.xml was just for Windows PE? Do I need to just copy the XML code into an autounattend.xml file?

    When I check the setupact.log file in "C:\Windows\Panther\UnattendGC" I see these lines:
    Code:
    2021-06-12 15:52:33, Info                         [Shell Unattend] Running 'oobeSystem' pass
    2021-06-12 15:52:33, Info                         [Shell Unattend] LogonCommands: Set command '%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe Set-ExecutionPolicy RemoteSigned -Force; tzutil /s 'GTB Standard Time'; set-culture en-GB; $LanguageList = Get-WinUserLanguageList; $LanguageList.Add('el-GR'); Set-WinUserLanguageList $LanguageList -Force; Powercfg /Change standby-timeout-ac 0; Powercfg /Change standby-timeout-dc 0;'
    2021-06-12 15:52:33, Info                         [Shell Unattend] Exiting 'oobeSystem' pass with status 0x00000000
    Does this mean that the command is processed?

    I have attached the file in case someone wants to see it. Thanks.
    FirstLogonCommands in unattend.xml do not work Attached Files
      My Computer


  4. Posts : 4,187
    Windows 11 Pro, 22H2
       #4

    It gets confusing. If you are going to sysprep an image then you will want a unattend.xml answer file. If you are doing only unattended setup, you will want to use an autounattend.xml answer file.

    See this for some more detail:

    Unattended Windows 10 questions (software, updates, computer name)

    I would suggest creating the answer file using the Windows System Image Manager.

    It's possible that this may work just with an unattend.xml answer file, but I have successfully used it with the autounattend.xml so I think that is worth a shot.

    I'll see if I can find anything more definitive on this and let you know what I find.
      My Computers


  5. Posts : 3
    10
    Thread Starter
       #5

    hsehestedt said:
    It gets confusing. If you are going to sysprep an image then you will want a unattend.xml answer file. If you are doing only unattended setup, you will want to use an autounattend.xml answer file.

    See this for some more detail:

    Unattended Windows 10 questions (software, updates, computer name)

    I would suggest creating the answer file using the Windows System Image Manager.

    It's possible that this may work just with an unattend.xml answer file, but I have successfully used it with the autounattend.xml so I think that is worth a shot.

    I'll see if I can find anything more definitive on this and let you know what I find.
    Thanks, I will take a look at that thread. Btw, I have tried using autounattend.xml instead, but I got an error about not specifying a product key or something.
      My Computer


  6. Posts : 4,187
    Windows 11 Pro, 22H2
       #6

    @rwayboy,

    If you have not looked at this tutorial yet, I would strongly recommend it. It's really excellent.

    Create media for automated unattended install of Windows 10

    A few notes:

    That tutorial assumes that you will create 2 answer files, the autounattend.xml and an unattend.xml. The reason for this is to allow you to create a reference system that you can completely customize by installing apps and customizing Windows settings and then capturing an image and finally deploying this with unattended setup.

    If you simply want to perform an unattended installation of Windows without capturing a customized image, then the process becomes much easier. If that is what you want to do, then start by taking a look at my post #299 within that same thread. You can find that here:

    Create media for automated unattended install of Windows 10

    That post simply tells you what steps of the original tutorial to follow and what to do differently to simply perform a straight unattended installation.

    Please do let me know if you have any questions!
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:51.
Find Us




Windows 10 Forums