Uso WDS su un server standalone per configurarne uno nuovo PC e per reimmaginare PC quando sono finiti mutilati in modo irreparabile. Con un buon numero di PC a casa mia è utile ricrearli di tanto in tanto durante lo scambio o l'aggiornamento dell'hardware. La maggior parte di questo processo è ora automatizzato da un file unattend.xml ma un passaggio che il processo automatico non sembra supportare è la ridenominazione PC tornano al loro nome originale.
Tutto il mio PC have static DHCP reservations with their correct hostname (che è anche registrato in DNS) so I figured there must be a way to pull this information and use it to rename them. After much fiddling about I have produced a batch script that will do this (quando eseguito come amministratore).
Simple paste the following code into a .cmd file and run it as part of your unattended process (Descrivo il mio qui sotto)
1 2 3 4 5 6 7 8 9 10 11 12 13 | @echo off set ip_address_string=“IPv4 Address” FOR /F “usebackq” %%i IN (‘hostname‘) DO SET MYVAR=%%i for /f “usebackq tokens=2 delims=:” %%f in (‘ipconfig ^| findstr /c:%ip_address_string%‘) do ( for /f “usebackq tokens=2 delims=:” %%g in (‘nslookup %%f ^| findstr /c:Name‘) do ( for /F “tokens=1 delims=.” %%a in (“%%g”) do ( for /F “tokens=1 delims= ” %%b in (“%%a”) do ( WMIC ComputerSystem where Name=”%myvar%” call Rename Name=”%%b” goto :eof ) ) ) ) |
Chiamo il mio script dal <FirstLogonCommands>
section of ImageUnattend.xml.
1 2 3 4 5 | <SynchronousCommand wcm:action=“add”> <Order>5</Order> <Description>Rename system</Description> <CommandLine>c:\extras\elevate -c c:\extras\rename-pc-from-dns.cmd</CommandLine> </SynchronousCommand> |
To run it as admin I use a little utility (chiamato elevate.exe) che fa questo (commands run during setup can elevate without popping up a prompt!). Puoi ottenerlo da it's fonte originale
The final piece of the puzzle for my setup is that I modify the windows install image to include an exe file and a little poweershell script — these allow the copying of all the other installers from the network. The exe file is ‘torrenti’ which is a sysinternals (ora parte di Microsoft) utility to remove the “this file came from the internet are you sure you want to run it” warning.
I also have the following script as a .ps1 file
1 | copy-item -Path \\wds-server\RemInst\Custom\*.* -Destination C:\Extras |
Il mio primo 4 LogonCommands are then as follows…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <SynchronousCommand wcm:action=“add”> <Order>1</Order> <Description>No standby during setup</Description> <CommandLine>powercfg -change standby-timeout-ac 0</CommandLine> </SynchronousCommand> <SynchronousCommand wcm:action=“add”> <Order>2</Order> <Description>Add credentials for access to server via network</Description> <CommandLine>cmdkey /add:wds-server /user:wds-server\administrator /pass:password123</CommandLine> </SynchronousCommand> <SynchronousCommand wcm:action=“add”> <Order>3</Order> <Description>Copy scripts and apps from network to extras folder</Description> <CommandLine>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -ExecutionPolicy ByPass -File C:\Extras\copyapps.ps1</CommandLine> </SynchronousCommand> <SynchronousCommand wcm:action=“add”> <Order>4</Order> <Description>Remove internet warning from copied apps</Description> <CommandLine>C:\Extras\Streams64.exe -d -d -nobanner C:\Extras\*.* /accepteula</CommandLine> </SynchronousCommand> |
Cosa ne pensi? Mandaci un commento qui sotto! Se si desidera iscriversi si prega di utilizzare il link iscriviti sul menu in alto a destra. È inoltre possibile condividere con i tuoi amici usando i link sottostanti sociali. Saluti.
lascia un commento