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.
So…

  • 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! 🙂

 

Remotely change Site Code WMIC SCCM CMD

Below is a quick WMIC CMD line that will change the site assignment of a client remotely. Bare in mind that account you use must have Administrative access to the machine you are targeting.

This version will read from a text file the machines that require the Site Code change. Again though, bare in mind that the account running the command must have Administrative access to the machines in question.

WordPress not creating Thumbnails for images on AWS EC2

I swapped my blog recently to AWS (Amazon Web Services) and am loving it! I was editing on of my post and uploaded a new image and noticed that WordPress was not automatically creating Thumbnails for my images. This is a real pain as you don’t want huge images littering your site for multiple reasons.

Anyway if you are Running WordPress from AWS (Amazon Web Services) EC2 using PHP70 then all you need to do is install PHP70-gd.

To do this… Putty into your server and type:

Next reboot your server from the AWS (Amazon Web Services) Management Console and upload an image to test.

Note: If you have a different version of PHP install just change the version number 70 in this case to that version.

Note: This will only work with new images uploaded after the fix is applied.

Export Sites and Subnets PowerShell to CSV

I came across an issue the other day when setting up a primary site for a customers Regional Office. The issue was that when enabling discovery methods namely the “Active Directory Forest Discovery“. As I’m sure you are aware there is a useful tick box that can be marked to “Automatically create IP address range boundaries for IP subnets when they are discovered“. This although a usually a useful check box caused the Discovery Method to pull back EVERY subnet listed globally… about 2500)!

So to get round this I created this PowerShell Script to export the Sites required and the Subnets associated with the sites in Active Directory Sites and Subnets. This script will export the data to a CSV that can then be imported into ConfigMgr later using this script.

Note: If you run the script without Parameters and just want to enter one Site to export, just hit enter on the next line and it will then ask you for save location.

Note: As in the image at the bottom of this page the save location must include the CSV Name e.g. “C:\temp\sites.csv”

The Image below shows the script being run and the output:

Export Sites and Subnets to CSV PowerShell Script
Export Sites and Subnets to CSV PowerShell Script

Copyright 2016 SCCMOG | All Rights Reserved