PowerShell Scripts in Windows Unattend Answer File XML

0

So I have a Windows 10 Unattend Answer File. I got the parts where it skips the OOBE screens, enables admin account, and copy profile. I am trying to set the answer file to run a PowerShell script to import the start menu from a xml file I made from a export of the start menu. The file is located on the C drive of the image, and the path is verified.

However when I add this Powershell command in to the answer file and run sysprep and reboot I get the following error upon Setting Up Windows: 'Windows could not parse or process unattend answer file C:\Windows\Panther\unattend.xml to pass [specialize]. A component or setting specified in the answer file does not exist.'

Here is the problematic unattend.xml:

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="specialize">
        <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">
            <AutoLogon>
                <Password>
                    <Value>P@ssword</Value>
                    <PlainText>true</PlainText>
                </Password>
                <Username>Administrator</Username>
                <Enabled>true</Enabled>
                <LogonCount>5</LogonCount>
            </AutoLogon>
            <StartTiles>
                <PromoteOEMTiles>false</PromoteOEMTiles>
            </StartTiles>
            <WindowsFeatures>
                <ShowInternetExplorer>true</ShowInternetExplorer>
                <ShowMediaCenter>false</ShowMediaCenter>
                <ShowWindowsMail>false</ShowWindowsMail>
                <ShowWindowsMediaPlayer>true</ShowWindowsMediaPlayer>
            </WindowsFeatures>
            <CopyProfile>true</CopyProfile>
            <DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
        </component>
        <component name="Microsoft-Windows-Deployment" 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">
            <FirstLogonCommands>

                <RunSynchronousCommand wcm:action="add">
                    <Description>Set Powershell Execution Policy to Unrestricted</Description>
                    <Path>powershell.exe Set-ExecutionPolicy Unrestricted -force</Path>
                    <Order>3</Order>
                </RunSynchronousCommand>

                <SynchronousCommand wcm:action="add">
                    <Order>4</Order>
                    <CommandLine>powershell.exe Import-StartLayout –LayoutPath C:\Installs\StartMenu.xml –MountPath $env:SystemDrive\</CommandLine>
                    <Description>Start Menu</Description>
         </SynchronousCommand>

            </FirstLogonCommands>
        </component>
    </settings>
    <settings pass="oobeSystem">
        <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>
                <HideLocalAccountScreen>true</HideLocalAccountScreen>
                <HideEULAPage>true</HideEULAPage>
                <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
                <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
                <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
                <SkipUserOOBE>true</SkipUserOOBE>
                <SkipMachineOOBE>true</SkipMachineOOBE>
            </OOBE>
            <UserAccounts>
                <AdministratorPassword>
                    <Value>P@ssword</Value>
                    <PlainText>true</PlainText>
                </AdministratorPassword>
            </UserAccounts>
        </component>
    </settings>
    <cpi:offlineImage cpi:source="wim:c:/users/tester/desktop/win10/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

Here is my last good, working unattend.xml:

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="specialize">
        <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">
            <WindowsFeatures>
                <ShowWindowsMail>false</ShowWindowsMail>
                <ShowInternetExplorer>true</ShowInternetExplorer>
            </WindowsFeatures>
            <CopyProfile>true</CopyProfile>
            <DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
            <AutoLogon>
                <Password>
                    <Value>Password123!</Value>
                    <PlainText>true</PlainText>
                </Password>
                <Username>Administrator</Username>
                <Enabled>true</Enabled>
                <LogonCount>5</LogonCount>
            </AutoLogon>
            <UserAccounts>
                <AdministratorPassword>
                    <Value>Password123!</Value>
                    <PlainText>true</PlainText>
                </AdministratorPassword>
            </UserAccounts>
        </component>
    </settings>
    <settings pass="oobeSystem">
        <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>
                <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
                <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
                <SkipMachineOOBE>true</SkipMachineOOBE>
                <SkipUserOOBE>true</SkipUserOOBE>
                <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
            </OOBE>
            <WindowsFeatures>
                <ShowInternetExplorer>true</ShowInternetExplorer>
                <ShowWindowsMail>false</ShowWindowsMail>
                <ShowWindowsMediaPlayer>true</ShowWindowsMediaPlayer>
            </WindowsFeatures>
            <BluetoothTaskbarIconEnabled>false</BluetoothTaskbarIconEnabled>
            <UserAccounts>
                <AdministratorPassword>
                    <Value>Password123</Value>
                    <PlainText>Password123</PlainText>
                </AdministratorPassword>
            </UserAccounts>
        </component>
    </settings>
    <cpi:offlineImage cpi:source="wim:c:/users/tester/desktop/win10/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

I have the PowerShell commands set in the unattend answer file with the tag.

Also here is the logs that I pulled from C:\Windows\Panther after Sysprep...

2018-07-23 10:38:29, Error                        [setup.exe] SMI data results dump: Source = Name: Microsoft-Windows-Deployment, Language: neutral, ProcessorArchitecture: amd64, PublicKeyToken: 31bf3856ad364e35, VersionScope: nonSxS, /settings/FirstLogonCommands

2018-07-23 10:38:29, Error                        [setup.exe] SMI data results dump: Description = Setting is not defined in this component.


2018-07-23 10:38:29, Error      [0x060432] IBS    The provided unattend file is not valid; hrResult = 0x80220001

2018-07-23 10:38:29, Error      [0x060565] IBS    Callback_Unattend_InitEngine:The provided unattend file [C:\Windows\Panther\unattend.xml] is not a valid unattended Setup answer file; hr = 0x1, hrSearched = 0x1, hrDeserialized = 0x0, hrImplicitCtx = 0x0, hrValidated = 0x1, hrResult = 0x80220001


2018-07-23 10:38:29, Error      [0x0600c2] IBS    Callback_Unattend_InitEngine:An error occurred while finding/loading the unattend file; hr = 0x1, hrResult = 0x80220001[gle=0x00000490]
windows-10
powershell
xml
unattended
answerfile
asked on Super User Jul 23, 2018 by ztmcoder • edited Jul 23, 2018 by ztmcoder

1 Answer

1
2018-07-23 10:38:29, Error                        [setup.exe] SMI data results dump: Source = Name: Microsoft-Windows-Deployment, Language: neutral, ProcessorArchitecture: amd64, PublicKeyToken: 31bf3856ad364e35, VersionScope: nonSxS, /settings/FirstLogonCommands

2018-07-23 10:38:29, Error                        [setup.exe] SMI data results dump: Description = Setting is not defined in this component.

Windows setup indicates you have put the "FirstLogonCommands" block in the wrong pass in the unnattend file.

You're using two different structures for running a command. You're using "RunSynchronousCommand" and "SynchronousCommand".

First, you should be using Windows System Image Manager to create unattend files. This will insure they are formatted correctly.

The problem here is that you are using the "RunSynchronousCommand" block which works during the specialize pass, or auditUser pass. It is supposed to be contained within a "RunSynchronous" block.

You've put in a "SynchronousCommand" block which runs during the oobeSystem pass after the first user logs on to the system. But, you've put it in the specialize pass.

The RunSynchronousCommand block has to be contained in a "RunSynchronous" block and located in the Specialize or auditUser pass. The SynchronousCommand block can only be located in the oobeSystem pass. For an explanation of Windows Setup Configuration Passes and when they run see here: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-setup-configuration-passes

You need to make a decision when you want these commands to run and then properly format the unattend file by placing the commands in the proper locations. Again, Windows System Image Manager would not have validated this file.

Most likely, you want to use only "SynchronousCommand" during the oobeSystem pass. However, be aware, that Windows 10 does not run these commands synchronously. Windows will NOT wait for these commands to finish before logging the user on, contrary to what Microsoft has specified in documentation. This is new for Windows 10.

answered on Super User Jul 23, 2018 by Appleoddity • edited Jul 23, 2018 by Appleoddity

User contributions licensed under CC BY-SA 3.0