J'utilise WDS sur un serveur autonome pour configurer de nouveaux PC et de réimager PC quand ils ont fini par être mutilés de manière irréparable. Avec un bon nombre de PC dans ma propre maison, il est utile de les réimager occasionnellement lors de l'échange ou de la mise à niveau du matériel. La plupart de ce processus est maintenant automatisé par un fichier unattend.xml, mais une étape que le processus sans surveillance ne semble pas prendre en charge est de renommer PC retour à leur nom d'origine.
Tout mon PC have static DHCP reservations with their correct hostname (qui est également enregistré dans 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 (lorsqu'il est exécuté en tant qu'administrateur).
Simple paste the following code into a .cmd file and run it as part of your unattended process (je décris le mien ci-dessous)
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 ) ) ) ) |
J'appelle mon script depuis le <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 (appelé elevate.exe) ça fait ça (commands run during setup can elevate without popping up a prompt!). Vous pouvez l'obtenir de c'est source d'origine
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 ‘flux’ which is a sysinternals (fait maintenant partie de 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 |
Mon premier 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> |
S'il vous plaît envoyez-nous vos pensées en commentant ci-dessous! Si vous souhaitez vous abonner s'il vous plaît utiliser le lien d'abonnement dans le menu en haut à droite. Vous pouvez également partager avec vos amis en utilisant les liens sociaux ci-dessous. À votre santé.
Laisser un commentaire