Wie führe ich Skripts vom Installationsmedium in einer autounattend.xml-Datei aus?

Wie führe ich Skripts vom Installationsmedium in einer autounattend.xml-Datei aus?

Ich habe einige PowerShell- (.ps1) und Batch- (.bat) Skripte erstellt, die ich in eine automatisierte Windows-Installation integrieren möchte. Alles andere habe ich bereits in meiner Datei autounattend.xml mit dem Windows System Image Manager konfiguriert und es funktioniert einwandfrei, mit Ausnahme der Ausführung meiner Skripte.

Bevor ich versuchte, vollständig zu automatisieren, wechselte ich in den Überwachungsmodus (STRG+UMSCHALT+F3), um die OOBE zu umgehen, und führte dann meine Skripte von dort aus aus. Da ich wusste, dass meine Skripte im Überwachungsmodus funktionierten, entschied ich mich, im Windows System Image Manager bei Pass 6 audituser synchrone Befehle einzufügen.

Dies ist meine bisherige autouattend.xml-Datei

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <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">
            <AutoLogon>
                <Password>
                    <Value>cABhAHMAcwB3AG8AcgBkAFAAYQBzAHMAdwBvAHIAZAA=</Value>
                    <PlainText>false</PlainText>
                </Password>
                <Enabled>true</Enabled>
                <LogonCount>3</LogonCount>
                <Username>LocalAdmin</Username>
            </AutoLogon>
            <UserAccounts>
                <LocalAccounts>
                    <LocalAccount wcm:action="add">
                        <Password>
                            <Value>cABhAHMAcwB3AG8AcgBkAFAAYQBzAHMAdwBvAHIAZAA=</Value>
                            <PlainText>false</PlainText>
                        </Password>
                        <Name>LocalAdmin</Name>
                        <Group>Administrators</Group>
                        <DisplayName></DisplayName>
                        <Description>Local adminstrator stored on the system drive</Description>
                    </LocalAccount>
                </LocalAccounts>
            </UserAccounts>
            <OOBE>
                <SkipMachineOOBE>true</SkipMachineOOBE>
                <SkipUserOOBE>true</SkipUserOOBE>
                <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
                <HideEULAPage>true</HideEULAPage>
            </OOBE>
        </component>
    </settings>
    <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">
            <EnableNetwork>false</EnableNetwork>
            <DiskConfiguration>
                <Disk wcm:action="add">
                    <CreatePartitions>
                        <CreatePartition wcm:action="add">
                            <Order>1</Order>
                            <Size>500</Size>
                            <Type>Primary</Type>
                        </CreatePartition>
                        <CreatePartition wcm:action="add">
                            <Order>2</Order>
                            <Type>EFI</Type>
                            <Size>100</Size>
                        </CreatePartition>
                        <CreatePartition wcm:action="add">
                            <Order>4</Order>
                            <Extend>true</Extend>
                            <Type>Primary</Type>
                        </CreatePartition>
                        <CreatePartition wcm:action="add">
                            <Order>3</Order>
                            <Size>16</Size>
                            <Type>MSR</Type>
                        </CreatePartition>
                    </CreatePartitions>
                    <ModifyPartitions>
                        <ModifyPartition wcm:action="add">
                            <Format>NTFS</Format>
                            <Label></Label>
                            <Order>1</Order>
                            <PartitionID>1</PartitionID>
                            <TypeID>DE94BBA4-06D1-4D40-A16A-BFD50179D6AC</TypeID>
                        </ModifyPartition>
                        <ModifyPartition wcm:action="add">
                            <Order>2</Order>
                            <Format>FAT32</Format>
                            <PartitionID>2</PartitionID>
                            <Label>System</Label>
                        </ModifyPartition>
                        <ModifyPartition wcm:action="add">
                            <PartitionID>3</PartitionID>
                            <Order>3</Order>
                        </ModifyPartition>
                        <ModifyPartition wcm:action="add">
                            <PartitionID>4</PartitionID>
                            <Order>4</Order>
                            <Format>NTFS</Format>
                        </ModifyPartition>
                    </ModifyPartitions>
                    <WillWipeDisk>true</WillWipeDisk>
                    <DiskID>0</DiskID>
                </Disk>
            </DiskConfiguration>
            <ImageInstall>
                <OSImage>
                    <InstallTo>
                        <DiskID>0</DiskID>
                        <PartitionID>4</PartitionID>
                    </InstallTo>
                    <InstallFrom>
                        <MetaData wcm:action="add">
                            <Key>/IMAGE/NAME</Key>
                            <Value>Windows 10 Pro</Value>
                        </MetaData>
                    </InstallFrom>
                </OSImage>
            </ImageInstall>
            <UserData>
                <ProductKey>
                    <WillShowUI>OnError</WillShowUI>
                    <Key />
                </ProductKey>
                <AcceptEula>true</AcceptEula>
            </UserData>
        </component>
        <component name="Microsoft-Windows-International-Core-WinPE" 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">
            <SetupUILanguage>
                <UILanguage>en-gb</UILanguage>
            </SetupUILanguage>
            <InputLocale>en-gb</InputLocale>
            <SystemLocale>en-gb</SystemLocale>
            <UILanguageFallback>en-us</UILanguageFallback>
            <UILanguage>en-gb</UILanguage>
        </component>
    </settings>
    <settings pass="auditUser">
        <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">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Order>2</Order>
                    <Path>powershell.exe -executionpolicy remotesigned -File &quot;Files\Scripts\2A-Create_Daily_System_Restore_Point.ps1&quot;</Path>
                </RunSynchronousCommand>
                <RunSynchronousCommand wcm:action="add">
                    <Description>Remove Windows Bloatware Provisioned Apps</Description>
                    <Order>1</Order>
                    <Path>powershell.exe -executionpolicy remotesigned -File &quot;%~dp0\Files\Scripts\1-Remove_Bloatware_Apps.ps1&quot;</Path>
                </RunSynchronousCommand>
                <RunSynchronousCommand wcm:action="add">
                    <Order>3</Order>
                    <Path>cmd.exe /c %~dp0\Files\Scripts\3-Remove_Folders_from_This_PC.bat</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
        </component>
    </settings>
    <cpi:offlineImage cpi:source="wim:d:/users/will/documents/it%20projects/windows%2010%20image/install.wim#Windows 10 Home" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

Ich werde ein Verzeichnis namens „Scripts“ im Stammverzeichnis des Windows-Installationsmediums anlegen. Meine Frage ist daher, wie ich diese Skripts in der Datei autounattend.xml vom Installationsmedium aus aufrufen kann. Gibt es eine Variable, die auf das Laufwerk und den Pfad verweist, auf dem sich das Installationsmedium befindet?

Antwort1

Ich glaube, ich habe die Lösung gefunden.

  1. Extrahieren Sie das ISO/Windows-Installationsmedium in einen Ordner
  2. Erstellen Sie einen Ordner im sources\Verzeichnis des extrahierten Installationsmediums mit dem Namen$OEM$
  3. Spiegeln Sie das Systemlaufwerk, sodass Sie ein Verzeichnis mit dem folgenden Pfad habensources\$OEM$\$$\Setup\Scripts (C:\Windows\Setup\Scripts)

Der Ordner $OEM$ spiegelt das Systemlaufwerk, sodass alles in diesen Ordnern während der Installation kopiert wird. In Bezug auf die Skripte, die aus der Datei autounattend.xml ausgeführt werden, müssen Sie die Skripte einfach von%SystemDrive%\WinDir\Setup\Scripts

Weitere Informationen finden Sie hier >https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh825027%28v%3dwin.10%29

Antwort2

Soweit ich weiß, wird der auditUserPass während der Windows-Installation nicht ausgeführt, es sei denn, das System wird in den Überwachungsmodus versetzt. Daher gibt es neben Ihrer Lösung zwei weitere mögliche Lösungen:

  1. Geben Sie Ihre Befehle in den specializeBuchstaben pass oder oobeSystempass ein. Normalerweise wird dem Installationsmedium der Buchstabe zugewiesen X:, aber wenn Sie sicherstellen möchten, dass das Setup die Skripte findet, können Sie eine Bedingung wie diese verwenden:
                <RunSynchronousCommand wcm:action="add">
                    <Description>Run script</Description>
                    <Order>1</Order>
                    <!-- Enumerate through all drives looking for the MYIT_OEMBypass.ps1 script, if found, run it. Leave the command prompt open. -->
                    <Path>cmd /c "(FOR %i IN (C D E F G H I J K L N M) DO IF EXIST %i:\MYIT_OEMBypass.ps1 Powershell -executionpolicy ByPass %i:\MYIT_OEMBypass.ps1) & pause"</Path>
                </RunSynchronousCommand>
  1. Weisen Sie das Windows-Setup an, direkt in den Überwachungsmodus (Sysprep) zu wechseln, wenn die oobeSystemAusführung des Passes beginnt, indem Sie Folgendes eingeben:
        <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">
            <Reseal>
                <Mode>Audit</Mode>
                <ForceShutdownNow>false</ForceShutdownNow>
            </Reseal>
        </component>

Mit dieser Methode können Siekann behaltenIhre Befehle im auditUserPass. Dies hilft auch beim Einrichten eines Standardprofils mit all Ihren bevorzugten Optimierungen, sodass alle später erstellten Profile auch alle diese Optimierungen enthalten.

Standardmäßig ist jedoch dieAutounattend.xml wird kopiert und als unattend.xml-Skript von sysprep festgelegt, was offensichtlich zu Problemen führen würde. Sie müssen also einige kleinere Änderungen vornehmen, um sysprep anzuweisen, einandersunattend.xml. Eine ausführlichere Anleitung für diese Methode finden Sie hier: https://rzander.azurewebsites.net/modern-os-deployment-mosd/

verwandte Informationen