joschfn
Goto Top

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:

@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

Content-Key: 240691

Url: https://administrator.de/contentid/240691

Printed on: April 18, 2024 at 11:04 o'clock

Member: JoSchFN
JoSchFN Jun 12, 2014 updated at 06:59:48 (UTC)
Goto Top
Sieht sieht die Ausgabe aus, wenn ich sie in eine Datei umleite:


C:\Install>setlocal EnableDelayedExpansion

C:\Install>set Hostname=Server01

C:\Install>set ImageGroupName="Win7 x64"

C:\Install>set BootImagePath=

C:\Install>set BootImageName="BootImage - WIN7 x64 Pro SP1 German clients"

C:\Install>set InstallImagePath=

C:\Install>set UnattendFileName_Client=win7_unattend_client.xml

C:\Install>set UnattendFileName_RALRKE=win7_unattend_RALRKE.xml

C:\Install>set UnattendFilePath_Client="C:\Install\win7_unattend_client.xml"

C:\Install>set UnattendFilePath_RALRKE="C:\Install\win7_unattend_RALRKE.xml"

C:\Install>echo.


C:\Install>echo Initialize WDS Server
Initialize WDS Server

C:\Install>echo ------------------------------------------------------------

C:\Install>echo 11.06.2014 23:36:34,58 - Initialize WDS Server 1>>C:\Startup_Logging.txt

C:\Install>wdsutil /initialize-server /server:Server01 /reminst:"D:\RemoteInstall"
ÿþ
W i n d o w s D e p l o y m e n t S e r v i c e s M a n a g e m e n t U t i l i t y [ V e r s i o n 6 . 1 . 7 6 0 0 . 1 6 3 8 5 ]
C o p y r i g h t ( C ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .

T h e c o m m a n d c o m p l e t e d s u c c e s s f u l l y .

C:\Install>echo 11.06.2014 23:36:40,04 - Initialize WDS Server finished - Errorlevel: 0 1>>C:\Startup_Logging.txt

C:\Install>echo.


C:\Install>if exist win7_unattend_client.xml copy "C:\Install\win7_unattend_client.xml" "D:\RemoteInstall\WDSClientUnattend"
1 file(s) copied.

C:\Install>if exist win7_unattend_RALRKE.xml copy "C:\Install\win7_unattend_RALRKE.xml" "D:\RemoteInstall\WDSClientUnattend"
1 file(s) copied.

C:\Install>wdsutil /set-server /wdsunattend /policy:enabled /file:wdsclientunattend\win7_unattend_client.xml /Architecture:x86
ÿþ
W i n d o w s D e p l o y m e n t S e r v i c e s M a n a g e m e n t U t i l i t y [ V e r s i o n 6 . 1 . 7 6 0 0 . 1 6 3 8 5 ]
C o p y r i g h t ( C ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .

T h e c o m m a n d c o m p l e t e d s u c c e s s f u l l y .

C:\Install>wdsutil /set-server /wdsunattend /policy:enabled /file:wdsclientunattend\win7_unattend_client.xml /Architecture:x64
ÿþ
W i n d o w s D e p l o y m e n t S e r v i c e s M a n a g e m e n t U t i l i t y [ V e r s i o n 6 . 1 . 7 6 0 0 . 1 6 3 8 5 ]
C o p y r i g h t ( C ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .

T h e c o m m a n d c o m p l e t e d s u c c e s s f u l l y .

C:\Install>wdsutil /add-imagegroup /imagegroup:"Win7 x64" /server:Server01
ÿþ
W i n d o w s D e p l o y m e n t S e r v i c e s M a n a g e m e n t U t i l i t y [ V e r s i o n 6 . 1 . 7 6 0 0 . 1 6 3 8 5 ]
C o p y r i g h t ( C ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .

T h e c o m m a n d c o m p l e t e d s u c c e s s f u l l y .

C:\Install>wdsutil /set-server /usedhcpports:no /dhcpoption60:yes
ÿþ
W i n d o w s D e p l o y m e n t S e r v i c e s M a n a g e m e n t U t i l i t y [ V e r s i o n 6 . 1 . 7 6 0 0 . 1 6 3 8 5 ]
C o p y r i g h t ( C ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .

T h e c o m m a n d c o m p l e t e d s u c c e s s f u l l y .

C:\Install>wdsutil /set-server /answerclients:known /responsedelay:0
ÿþ
W i n d o w s D e p l o y m e n t S e r v i c e s M a n a g e m e n t U t i l i t y [ V e r s i o n 6 . 1 . 7 6 0 0 . 1 6 3 8 5 ]
C o p y r i g h t ( C ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .

T h e c o m m a n d c o m p l e t e d s u c c e s s f u l l y .

C:\Install>wdsutil /set-server /architecturediscovery:yes
ÿþ
W i n d o w s D e p l o y m e n t S e r v i c e s M a n a g e m e n t U t i l i t y [ V e r s i o n 6 . 1 . 7 6 0 0 . 1 6 3 8 5 ]
C o p y r i g h t ( C ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .

T h e c o m m a n d c o m p l e t e d s u c c e s s f u l l y .

C:\Install>reg add HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\WDSServer\Parameters /v "UdpPortPolicy" /t REG_DWORD /d "0" /f 1>nul 2>&1

C:\Install>echo.


C:\Install>echo Find BOOT images and add it to WDS
Find BOOT images and add it to WDS

C:\Install>echo ------------------------------------------------------------

C:\Install>echo 11.06.2014 23:36:40,58 - Add BOOT Image to WDS 1>>C:\Startup_Logging.txt

C:\Install>for %a in ("D:\MSI2008\WDS\Boot\*.wim") do (
set BootImagePath=%a
echo !BootImagePath!
wdsutil /add-image /imagefile:!BootImagePath! /imagetype:boot /name:"BootImage - WIN7 x64 Pro SP1 German clients"
echo 11.06.2014 23:36:40,60 - BOOT Image !BootImagePath! added
echo 11.06.2014 23:36:40,60 - BOOT Image !BootImagePath! added - Errorlevel: 0 1>>C:\Startup_Logging.txt
)

C:\Install>(
set BootImagePath=D:\MSI2008\WDS\Boot\boot_image_x86.wim
echo !BootImagePath!
wdsutil /add-image /imagefile:!BootImagePath! /imagetype:boot /name:"BootImage - WIN7 x64 Pro SP1 German clients"
echo 11.06.2014 23:36:40,60 - BOOT Image !BootImagePath! added
echo 11.06.2014 23:36:40,60 - BOOT Image !BootImagePath! added - Errorlevel: 0 1>>C:\Startup_Logging.txt
)
D:\MSI2008\WDS\Boot\boot_image_x86.wim
ÿþ
W i n d o w s D e p l o y m e n t S e r v i c e s M a n a g e m e n t U t i l i t y [ V e r s i o n 6 . 1 . 7 6 0 0 . 1 6 3 8 5 ]
C o p y r i g h t ( C ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .

T h e c o m m a n d c o m p l e t e d s u c c e s s f u l l y .
11.06.2014 23:36:40,60 - BOOT Image D:\MSI2008\WDS\Boot\boot_image_x86.wim added

C:\Install>echo 11.06.2014 23:36:45,15 - BOOT Image added - Errorlevel: 0 1>>C:\Startup_Logging.txt

C:\Install>echo.


C:\Install>echo Find INSTALL images and add it to WDS
Find INSTALL images and add it to WDS

C:\Install>echo ------------------------------------------------------------

C:\Install>echo 11.06.2014 23:36:45,15 - Add INSTALL Images to WDS 1>>C:\Startup_Logging.txt

C:\Install>for %a in ("D:\MSI2008\WDS\Install\*.wim") do (
set ImagePath=%a
find /c /i "rocky" 1>NUL
if 0 == 0 (
echo wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:"Win7 x64" /unattendfile:win7_unattend_RALRKE.xml
wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:"Win7 x64" /unattendfile:win7_unattend_RALRKE.xml
echo 11.06.2014 23:36:45,15 - INSTALL Image !InstallImagePath! added
echo 11.06.2014 23:36:45,15 - INSTALL Image !InstallImagePath! added - Errorlevel: 0 1>>C:\Startup_Logging.txt
) else (
echo wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:"Win7 x64" /unattendfile:win7_unattend_client.xml
wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:"Win7 x64" /unattendfile:win7_unattend_client.xml
echo 11.06.2014 23:36:45,15 - INSTALL Image !InstallImagePath! added
echo 11.06.2014 23:36:45,15 - INSTALL Image !InstallImagePath! added - Errorlevel: 0 1>>C:\Startup_Logging.txt
)
)

C:\Install>(
set ImagePath=D:\MSI2008\WDS\Install\HP_Z400_Z420_WIN7.wim
find /c /i "rocky" 1>NUL
if 0 == 0 (
echo wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:"Win7 x64" /unattendfile:win7_unattend_RALRKE.xml
wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:"Win7 x64" /unattendfile:win7_unattend_RALRKE.xml
echo 11.06.2014 23:36:45,15 - INSTALL Image !InstallImagePath! added
echo 11.06.2014 23:36:45,15 - INSTALL Image !InstallImagePath! added - Errorlevel: 0 1>>C:\Startup_Logging.txt
) else (
echo wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:"Win7 x64" /unattendfile:win7_unattend_client.xml
wdsutil /add-image /imagefile:!ImagePath! /imagetype:install /imagegroup:"Win7 x64" /unattendfile:win7_unattend_client.xml
echo 11.06.2014 23:36:45,15 - INSTALL Image !InstallImagePath! added
echo 11.06.2014 23:36:45,15 - INSTALL Image !InstallImagePath! added - Errorlevel: 0 1>>C:\Startup_Logging.txt
)
)