Eu uso o WDS em um servidor autônomo para configurar novos PCs e recriar PCs quando eles acabam mutilados além do reparo. Com um bom número de PCs na minha própria casa é útil recriá-los ocasionalmente ao trocar ou atualizar o hardware. A maior parte desse processo agora é automatizado por um arquivo unattend.xml, mas uma etapa que o processo autônomo não parece suportar é a renomeação PCs de volta ao nome original.
Todo o meu PCs have static DHCP reservations with their correct hostname (que também está registrado em 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 executado como administrador).
Simple paste the following code into a .cmd file and run it as part of your unattended process (Eu descrevo o meu abaixo)
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 ) ) ) ) |
Eu chamo meu script do <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 (chamado elevate.exe) isso faz isso (commands run during setup can elevate without popping up a prompt!). Você pode obtê-lo fonte original
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 ‘streams’ which is a sysinternals (agora parte da 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 |
Meu primeiro 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> |
Acho que perdemos algo? Deixe-nos saber por comentar abaixo. Se você deseja se inscrever, use o link de inscrição no menu no canto superior direito. Você também pode compartilhar isso com seus amigos usando os links sociais abaixo. Felicidades.
Deixe uma resposta