0بیچ اسکرپٹ محفوظ DHCP نام کی بنیاد پر پی سی کا نام تبدیل کریں

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 (جس میں بھی درج ہے DNS) 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="IPv4 ایڈریس"
فار / ایف "استعمال بیک" %%میں میں (`میزبان نام`) DO SET MYVAR=%%i
for /f "usebackq ٹوکن = 2 حدود =:" %%f in (ip ipconfig ^| findstr / c:%ip_address_string٪ `) کیا (
    کے لئے / ایف "usebackq ٹوکن = 2 حدود =:" %%جی اندر (s n نگاہ ٪٪ f ^| findstr / c:نام`) کیا (
        کے لئے / ایف "ٹوکن = 1 حد بندی =۔" %%ایک میں ("%%g") کیا (
            کے لئے / ایف "ٹوکن = 1 حد بندی = " %%بی میں ("%%ایک") کیا (
                WMIC کمپیوٹر سسٹم جہاں نام ="%myvar٪" نام بدلیں نام ="%%B"
                کے پاس جاؤ :eof
            )
        )
    )
)

میں اپنی اسکرپٹ کو خدا کی طرف سے کال کرتا ہوں <FirstLogonCommands> sec­tion of ImageUnattend.xml.

<ہم وقت ساز کمانڈ ڈبلیو سی ایم:کارروائی ="شامل">
  <ترتیب>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!). آپ اسے اسی سے حاصل کرسکتے ہیں ori­gin­al source

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-سرور  ریمائنسٹ  اپنی مرضی کے مطابق. *. *:\ایکسٹرا

میرا پہلا 4 Logon­Com­mands are then as follows…

<ہم وقت ساز کمانڈ ڈبلیو سی ایم:کارروائی ="شامل">
  <ترتیب>1</ترتیب>
  <تفصیل>سیٹ اپ کے دوران کوئی اسٹینڈ بائی نہیں</تفصیل>
  <کمانڈ لائن>پاورکفگ چینج اسٹینڈ بائی ٹائم آؤٹ-ایک 0</کمانڈ لائن>
</ہم وقت ساز کامانڈ>
<ہم وقت ساز کمانڈ ڈبلیو سی ایم:کارروائی ="شامل">
  <ترتیب>2</ترتیب>
  <تفصیل>نیٹ ورک کے توسط سے سرور تک رسائی کے ل cred اسناد شامل کریں</تفصیل>
  <کمانڈ لائن>cmdkey / شامل کریں:wds-سرور / صارف:wds-سرور  ایڈمنسٹریٹر / پاس:پاس ورڈ 123</کمانڈ لائن>
</ہم وقت ساز کامانڈ>
<ہم وقت ساز کمانڈ ڈبلیو سی ایم:کارروائی ="شامل">
  <ترتیب>3</ترتیب>
  <تفصیل>اسکرپٹس اور ایپس کو نیٹ ورک سے ایکسٹرا فولڈر میں کاپی کریں</تفصیل>
  <کمانڈ لائن>سی:\ونڈوز  سسٹم 32  ونڈوز پاورشیل  v1.0  پاور شیل.ایکس - ونڈوز اسٹائل پوشیدہ:\ایکسٹرا  copyapps.ps1</کمانڈ لائن>
</ہم وقت ساز کامانڈ>
<ہم وقت ساز کمانڈ ڈبلیو سی ایم:کارروائی ="شامل">
  <ترتیب>4</ترتیب>
  <تفصیل>کاپی شدہ ایپس سے انٹرنیٹ وارننگ ہٹا دیں</تفصیل>
  <کمانڈ لائن>سی:\ایکسٹرا  اسٹریمز 64.exe -d -d -nobanner C:\ایکسٹرا  *. * / قبولیوٹی</کمانڈ لائن>
</ہم وقت ساز کامانڈ>

جواب چھوڑیں