DIY मीडिया होम लोगो

अपनी खुद की होम थिएटर और हाय-Fi सेटअप डिजाइन और बनाने के लिए परम साइट.

0आरक्षित डीएचसीपी नाम के आधार पर पीसी का नाम बदलने के लिए बैच स्क्रिप्ट

I use WDS on a stan­dalone serv­er to set up new पीसी and to reim­age पीसी when they have ended up mangled bey­ond repair. With a good num­ber of पीसी in my own house it is use­ful to reim­age them oca­sion­ally when swap­ping or upgrad­ing hard­ware. Most of this pro­cess is now auto­mated by an unattend.xml file but one step the unat­ten­ded pro­cess does­n’t seem to sup­port is renam­ing पीसी back to their ori­gin­al name.

मेरे सभी पीसी have stat­ic DHCP reser­va­tions with their cor­rect host­name (जो registered में भी पंजीकृत है डीएनएस) so I figured there must be a way to pull this inform­a­tion and use it to rename them. After much fid­dling about I have pro­duced a batch script that will do this (जब व्यवस्थापक के रूप में चलाया जाता है).

Simple paste the fol­low­ing code into a .cmd file and run it as part of your unat­ten­ded pro­cess (मैं नीचे मेरा वर्णन करता हूं)

@echo off
set ip_address_string="आईपीवी4 पता"
के लिए / एफ "यूज़बैकक्यू" %%मैं में (`होस्टनाम`) DO SET MYVAR=%%i
for /f "usebackq टोकन = २ परिसीमन =:" %%एफ इन (`आईपीकॉन्फिग ^| खोज/सी:%ip_address_string%`) कर (
    के लिए / एफ "usebackq टोकन = २ परिसीमन =:" %%जिन (`एनएसलुकअप %%f ^| खोज/सी:नाम `) कर (
        के लिए / एफ "टोकन = 1 परिसीमन =।" %%एक in ("%%g") कर (
            के लिए / एफ "टोकन = 1 परिसीमन = " %%बी इन ("%%a") कर (
                WMIC कंप्यूटर सिस्टम जहां नाम ="%मायवर%" कॉल का नाम बदलें नाम ="%%बी"
                के लिए जाओ :ईओएफ
            )
        )
    )
)

मैं अपनी स्क्रिप्ट को से बुलाता हूं <FirstLogonCommands> sec­tion of ImageUnattend.xml.

<सिंक्रोनस कमांड wcm:क्रिया ="जोड़ना">
  <गण>5</गण>
  <विवरण>सिस्टम का नाम बदलें</विवरण>
  <कमांड लाइन>सी:\अतिरिक्तऊंचाई -सी सी:\अतिरिक्तनाम बदलें-पीसी-से-dns.cmd</कमांड लाइन>
</सिंक्रोनस कमांड>

To run it as admin I use a little util­ity (कहा जाता है) जो यह करता है (com­mands run dur­ing setup can elev­ate without pop­ping up a prompt!). आप इसे इसके से प्राप्त कर सकते हैं मूल स्रोत

The final piece of the puzzle for my setup is that I modi­fy the win­dows install image to include an exe file and a little poweer­shell script — these allow the copy­ing of all the oth­er installers from the net­work. The exe file is ‘धाराओं’ which is a sys­in­tern­als (अब माइक्रोसॉफ्ट का हिस्सा) util­ity to remove the “this file came from the inter­net are you sure you want to run it” warning.

I also have the fol­low­ing script as a .ps1 file

कॉपी-आइटम -पथ \wds-serverRemInstCustom*.* -गंतव्य सी:\अतिरिक्त

मेरा पहला 4 Logon­Com­mands are then as follows…

<सिंक्रोनस कमांड wcm:क्रिया ="जोड़ना">
  <गण>1</गण>
  <विवरण>सेटअप के दौरान कोई स्टैंडबाय नहीं</विवरण>
  <कमांड लाइन>powercfg -स्टैंडबाय-टाइमआउट-एसी 0 . बदलें</कमांड लाइन>
</सिंक्रोनस कमांड>
<सिंक्रोनस कमांड wcm:क्रिया ="जोड़ना">
  <गण>2</गण>
  <विवरण>नेटवर्क के माध्यम से सर्वर तक पहुंच के लिए क्रेडेंशियल जोड़ें</विवरण>
  <कमांड लाइन>cmdkey /add:डब्ल्यूडीएस-सर्वर / उपयोगकर्ता:wds-सर्वरव्यवस्थापक / पास:पासवर्ड123</कमांड लाइन>
</सिंक्रोनस कमांड>
<सिंक्रोनस कमांड wcm:क्रिया ="जोड़ना">
  <गण>3</गण>
  <विवरण>स्क्रिप्ट और ऐप्स को नेटवर्क से एक्स्ट्रा फोल्डर में कॉपी करें</विवरण>
  <कमांड लाइन>C:\WindowsSystem32WindowsPowerShellv1.0powershell.exe -विंडोस्टाइल छिपा हुआ - एक्ज़ीक्यूशन पॉलिसी बायपास -फाइल सी:\अतिरिक्त  copyapps.ps1</कमांड लाइन>
</सिंक्रोनस कमांड>
<सिंक्रोनस कमांड wcm:क्रिया ="जोड़ना">
  <गण>4</गण>
  <विवरण>कॉपी किए गए ऐप्स से इंटरनेट चेतावनी हटाएं</विवरण>
  <कमांड लाइन>C:\अतिरिक्त  Streams64.exe -d -d -nobanner C:\अतिरिक्त*.* /स्वीकृति</कमांड लाइन>
</सिंक्रोनस कमांड>

उत्तर छोड़ दें