Automation

Now let's put this all together in with some Automation

AutoUnattend.xml

Everything can be added to an AutoUnattend.xml in three separate Commands

Execution Policy

The Execution Policy must be run first as the OSD Module will not be imported without having this done first. We know this works properly, so -WindowStyle Hidden will be used to hide the console

Add Modules

The second Command will update the OSD Module and add additional Modules. This must be kept separate so additional Run Commands that are in additional steps will use the updated Modules. This window will be kept visible and a Pause will be added. Verbose output is recommended

Commands

Finally, all the other settings can be put together in the third command. Again, Verbose and a Pause will help for the test

    <settings pass="windowsPE">
        <component name="Microsoft-Windows-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">
            <UserData>
                <AcceptEula>true</AcceptEula>
                <ProductKey>
                    <Key>NPPR9-FWDCX-D2C8J-H872K-2YT43</Key>
                    <WillShowUI>Never</WillShowUI>
                </ProductKey>
            </UserData>
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Description>ExecutionPolicy Bypass</Description>
                    <Path>PowerShell -WindowStyle Hidden -Command "Set-ExecutionPolicy Bypass"</Path>
                </RunSynchronousCommand>
                <RunSynchronousCommand wcm:action="add">
                    <Order>2</Order>
                    <Description>Add PowerShell Modules</Description>
                    <Path>PowerShell -Command "& {OSDWinPE -Modules -Verbose; Pause}"</Path>
                </RunSynchronousCommand>
                <RunSynchronousCommand wcm:action="add">
                    <Order>3</Order>
                    <Description>OSD Settings</Description>
                    <Path>PowerShell -Command "& {OSDPower High -Verbose; OSDWinPE -InitializeNetwork -DisableFirewall -UpdateBootInfo -RemoteRecovery -Verbose; Pause}"</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
        </component>
    </settings>

Execution

The first console that we see is to add the Modules. Press Enter to continue

The second one is for the settings. Press Enter to continue

Full Automation

Once we verify that everything looks good, the Windows can be Hidden, and we can even use PowerShell Transcripts to see how things went. To fully automate everything, simply use the following commands in the AutoUnattend.xml

            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Description>ExecutionPolicy Bypass</Description>
                    <Path>PowerShell -WindowStyle Hidden -Command "Set-ExecutionPolicy Bypass"</Path>
                </RunSynchronousCommand>
                <RunSynchronousCommand wcm:action="add">
                    <Order>2</Order>
                    <Description>Add PowerShell Modules</Description>
                    <Path>PowerShell -WindowStyle Hidden -Command "& {Start-Transcript;OSDWinPE -Modules -Verbose;Stop-Transcript}"</Path>
                </RunSynchronousCommand>
                <RunSynchronousCommand wcm:action="add">
                    <Order>3</Order>
                    <Description>OSD Settings</Description>
                    <Path>PowerShell -WindowStyle Hidden -Command "& {Start-Transcript;OSDPower High -Verbose;OSDWinPE -InitializeNetwork -DisableFirewall -UpdateBootInfo -RemoteRecovery -Verbose;Stop-Transcript}"</Path>
                </RunSynchronousCommand>
            </RunSynchronous>

And this is the result, looks like nothing happened. Microsoft DaRT Remote Recovery will be accessible by pressing ALT + TAB

A closer look shows that everything is set properly

PowerShell Transcripts are saved in X:\Sources if you want a closer look

Last updated