Set static IP on VM Pre LiteTouch in WinPE – MDT VBScript

I was working on a client site last year and setting them up a reference image task sequence for Windows 10. The VMs that I was working with were hosted in a subnet that did not have DHCP configured. This gave me the issue of configuring the IP statically on the VM that was used to build and capture the reference image BEFORE light touch is launched. So I wrote this little script (with google’s help) to grab the MAC address of the virtual NIC that had been initialised on the VM, match it to a variable and set the IP accordingly to the adaptor by referencing its name.

To implement this script into your MDT boot image there are a couple of steps that have to be performed. The first is to tell the boot image to run it beofre litetouch is called! To do this we have to place an updated Unattend.xml into the boot image.

Thankfully MDT has a proccess for adding extrafiles to your bootimage.
But firtly, we need to get sort out the script and xml.

  • Create a folder called “Static IP”.

  • Then copy and paste the XML code from below into a text document and save it in the Static IP folder called “Unattend.xml”.

NOTE: This XML has been built to work with x64 boot images and x86.)

  • Now open notepad again, copy and paste the VBscript from below and then save it as “Set-WinPE-StaticIP.vbs” into the “Static IP” Folder.

  • Now identify the MAC address of the VM(s) you will be targeting as this is what the script identifies the machine with, and place them into the MAC address variable fields (strRefVM1 & strRefVM2).

  • Now populate the IPs as required.

  • At this point is up to you to find the description of the network adaptor as this is used to grab the MAC address. I have supplied the two that I usually see for HyperV and VMware VMs but it is always best to check!

  • So boot up your current MDT Boot ISO and grab the description from the network adaptor that has been initialised by running an “Ipconfig /all”.

  • Now copy and paste it into the variable value for “strNetworkAdapter” or just uncomment the one you require.

  • And finally comment out the Ethernet name (strEthName) that does NOT apply to your environment. For example if you are running Hyper V VMs comment out the VMware line and vice versa.

  • Now open MDT and right click your deployment share and click “properties”.

  • Now select the “Windows PE” tab.

  • For each boot image you require the static IPs to be set click browse on the “Extra directory to add” field and import the “Static IP” folder.

  • Next click Apply.

  • Now right click the deployment share and update your boot images.

  • And thats it! Mount the ISO on your VM and hey presto…. no more IP issues! ๐Ÿ™‚


4 Replies to “Set static IP on VM Pre LiteTouch in WinPE – MDT VBScript”

  1. Hi,
    Thank you for your blog post. I am trying to do something similar in our environment where we have relied on using VM Templates to deploy servers using the vCenter Deploy from template method.

    I have configured a MDT server with Task Sequences for WS2012R2 and WS2016 which I would to use for deploying new VM servers but I have run into a similar issue like the one you have described a solution, whereby we do not have DHCP on our server VLANs for various reasons…

    In my case I would like to use the built in BDD Welcome Screen Static IP option which seems to work but breaks when after it installs the OS and drivers etc and does a restart – at that point the WINPE looses the previously manually entered IP settings. I am still learning how to do scripting. I think your solution would work perfectly if your script could be adapted to re-use the MDT variables which I believe would have been captured before the start of the job. I think because the VM is being restarted the variables should still remain in memory?


    I will be grateful if you are able to shed any light on how I could get the Static IP addressing to work for deploying new VM individually using different IP addresses and Gateways.

    Many thanks!

    1. Hi Mark,

      Sorry for the late reply, we have been very busy.
      So if I understand correctly after the Windows setup phase has completed you no longer have a static IP configured?
      If that is the case in MDT

    2. Create a run command line step after the first gather step in WinPE Phase. Name it “Gather NIC Configuration Forced”
    3. the CMD line is as follows: “%ScriptRoot%\ZTINICConfig.wsf” /ForceCapture
    4. This should retain the NIC configuration for you during the OS Phase ๐Ÿ™‚
      To ensure it has worked hit F8 and get a CMD prompt up.
      Let the WinPE phase complete, as the CMD prompt is up the machine will not reboot.
      Then run: Notepad.exe c:\windows\panther\unattended.xml
      And scroll down until you find your IP Configuration, this will also show you how the TS works ๐Ÿ™‚
      Hope that helps!



  2. โ€œ%ScriptRoot%\ZTINICConfig.wsfโ€ /ForceCapture

    Thanks man !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.