Script für WDS Konfiguration mit unterschiedlichen XML Dateien
Hallo zusammen,
ich bin gerade dabei, die Windows Deployment Services (WDS) über ein Script automatisch zu konfigurieren. Dabei habe ich verschiedene Install-Images, welche je nach Namen unterschiedliche XML Dateien mit Konfigurationen erhalten. Das funktioniert eigentlich auch ganz gut. Nur im Punkt ":: find install images and add it to WDS" gibts noch Probleme. Dabei soll folgendes gemacht werden:
1.) Es soll der Ordner D:\MSI2008\WDS\Install nach allen vorhandenen .wim Dateien durchsucht werden
2.) Abhänging davon, ob im Dateinamen der Begriff "Rocky" vorkommt, soll entweder die Datei "win7_unattend_RALRKE.xml" oder die Datei "win7_unattend_client.xml" angehängt werden. Also wenn Rocky im Dateinamen vorhanden, dann "win7_unattend_RALRKE.xml" sonst "win7_unattend_client.xml".
Das Problem momentan ist, dass er einfach gar nichts macht. Evtl liegt am Aufbau der If Else Abfrage, aber sicher bin ich mir nicht.
Könnt Ihr mir weiterhelfen?
Danke schonmal
Gruß
JoSchFN
Hier noch mein Script:
ich bin gerade dabei, die Windows Deployment Services (WDS) über ein Script automatisch zu konfigurieren. Dabei habe ich verschiedene Install-Images, welche je nach Namen unterschiedliche XML Dateien mit Konfigurationen erhalten. Das funktioniert eigentlich auch ganz gut. Nur im Punkt ":: find install images and add it to WDS" gibts noch Probleme. Dabei soll folgendes gemacht werden:
1.) Es soll der Ordner D:\MSI2008\WDS\Install nach allen vorhandenen .wim Dateien durchsucht werden
2.) Abhänging davon, ob im Dateinamen der Begriff "Rocky" vorkommt, soll entweder die Datei "win7_unattend_RALRKE.xml" oder die Datei "win7_unattend_client.xml" angehängt werden. Also wenn Rocky im Dateinamen vorhanden, dann "win7_unattend_RALRKE.xml" sonst "win7_unattend_client.xml".
Das Problem momentan ist, dass er einfach gar nichts macht. Evtl liegt am Aufbau der If Else Abfrage, aber sicher bin ich mir nicht.
Könnt Ihr mir weiterhelfen?
Danke schonmal
Gruß
JoSchFN
Hier noch mein Script:
@echo on
:: define environment
setlocal EnableDelayedExpansion
:: set variables
set Hostname=%computername%
set ImageGroupName="Win7 x64"
set BootImagePath=
set BootImageName="BootImage - WIN7 x64 Pro SP1 German clients"
set InstallImagePath=
set UnattendFileName_Client=win7_unattend_client.xml
set UnattendFileName_RALRKE=win7_unattend_RALRKE.xml
set UnattendFilePath_Client="C:\Install\%UnattendFileName_Client%"
set UnattendFilePath_RALRKE="C:\Install\%UnattendFileName_RALRKE%"
:: initialize WDS Server
echo.
echo Initialize WDS Server
echo ------------------------------------------------------------
echo %date% %time% - Initialize WDS Server >> C:\Startup_Logging.txt
wdsutil /initialize-server /server:%Hostname% /reminst:"D:\RemoteInstall"
echo %date% %time% - Initialize WDS Server finished - Errorlevel: %errorlevel% >> C:\Startup_Logging.txt
echo.
:: copy wdsunattend image files
if exist %UnattendFileName_Client% copy %UnattendFilePath_Client% "D:\RemoteInstall\WDSClientUnattend"
if exist %UnattendFileName_RALRKE% copy %UnattendFilePath_RALRKE% "D:\RemoteInstall\WDSClientUnattend"
:: add wdsunattend image files
wdsutil /set-server /wdsunattend /policy:enabled /file:wdsclientunattend\%UnattendFileName_Client% /Architecture:x86
wdsutil /set-server /wdsunattend /policy:enabled /file:wdsclientunattend\%UnattendFileName_Client% /Architecture:x64
:: create image group
wdsutil /add-imagegroup /imagegroup:%ImageGroupName% /server:%Hostname%
:: configure dhcp and respond options
wdsutil /set-server /usedhcpports:no /dhcpoption60:yes
wdsutil /set-server /answerclients:known /responsedelay:0
:: enable x64 support
wdsutil /set-server /architecturediscovery:yes
:: enable check port usage before bind WDS to any port
:: refer to http://support.microsoft.com/kb/977512
reg add HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\WDSServer\Parameters /v "UdpPortPolicy" /t REG_DWORD /d "0" /f > nul 2>&1
:: find boot images and add it to WDS
echo.
echo Find BOOT images and add it to WDS
echo ------------------------------------------------------------
echo %date% %time% - Add BOOT Image to WDS >> C:\Startup_Logging.txt
for %%a in ("D:\MSI2008\WDS\Boot\*.wim") do (
set BootImagePath=%%a
echo !BootImagePath!
wdsutil /add-image /imagefile:!BootImagePath! /imagetype:boot /name:%bootimagename%
echo %date% %time% - BOOT Image !BootImagePath! added
echo %date% %time% - BOOT Image !BootImagePath! added - Errorlevel: %errorlevel% >> C:\Startup_Logging.txt
)
echo %date% %time% - BOOT Image added - Errorlevel: %errorlevel% >> C:\Startup_Logging.txt
:: find install images and add it to WDS
echo.
echo Find INSTALL images and add it to WDS
echo ------------------------------------------------------------
echo %date% %time% - Add INSTALL Images to WDS >> C:\Startup_Logging.txt
for %%a in ("D:\MSI2008\WDS\Install\*.wim") do (
set ImagePath=%%a
find /c /i "rocky" %ImagePath% > NUL
if %ERRORLEVEL%==0 (
echo wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:%imagegroupname% /unattendfile:%UnattendFileName_RALRKE%
wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:%imagegroupname% /unattendfile:%UnattendFileName_RALRKE%
echo %date% %time% - INSTALL Image !InstallImagePath! added
echo %date% %time% - INSTALL Image !InstallImagePath! added - Errorlevel: %errorlevel% >> C:\Startup_Logging.txt
) else (
echo wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:%imagegroupname% /unattendfile:%UnattendFileName_Client%
wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:%imagegroupname% /unattendfile:%UnattendFileName_Client%
echo %date% %time% - INSTALL Image !InstallImagePath! added
echo %date% %time% - INSTALL Image !InstallImagePath! added - Errorlevel: %errorlevel% >> C:\Startup_Logging.txt
)
)
echo %date% %time% - INSTALL Images successfully added - Errorlevel: %errorlevel% >> C:\Startup_Logging.txt
echo.
Pause
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 240691
Url: https://administrator.de/forum/script-fuer-wds-konfiguration-mit-unterschiedlichen-xml-dateien-240691.html
Ausgedruckt am: 25.04.2025 um 13:04 Uhr
1 Kommentar