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

 

PowerShell Export Collection Members to CSV SCCM ConfigMgr

I was at a client’s yesterday and wanted to “True Up” SCCM/ConfigMgr’s Collection memberships compared to a spread sheet they had of their servers. Now I’m not an Excel wizard by any stretch of the Imagination! So the client said “Can you get me a CSV with the server names listed”.

The next thing that happened is bellow! It’s really quite a simple script when you think about it. As always comments throughout the script explain what is happening.

Anyway here it is:

PowerShell Check Power Adapter Connected Upgrade UEFI/BIOS – SCCM Application

The other month I was asked by one of my clients to deploy a BIOS/UEFI upgrade to the HP Elite x2 1012 G1. Now this as we all know is fine and very normal, the only issue I had was ensuring that the Power adapter was connected before running the BIOS/UEFI upgrade. This is because.. when you use the force switch on the HP upgrade utility it does not check for the Power Adapter state and also bypasses low battery and will install regardless.

So I created a script….

This script is designed to be run with the BIOS/UEFI upgrade package within.

  1. It will check first the Hardware type of the device (2 being Laptop, 1 being Desktop) making sure it is a mobile device.
  2. The script will then check the WMI property “PowerOnLine” to establish whether or not the power adapter is connected.
  3. If the Power Adapter is connected it will continue with the BIOS/UEFI upgrade (Jump to step 5)
  4. If the Power Adapter is not connected  it will warn the user 10 times before closing and informing the User to Re-Run the application from Software Center when power is available. (Warning count is customizable)
  5. The script will then identify the BIOS/UEFI version and if it is less that the version being deployed it will then warn and install the new BIOS/UEFI version.
  6. The script also does error checking around the Model of the machine.

Anyway enough already… Here is the script. As always feel free to use it but don’t forget where you got it from!

SCCM Auto Snapshot a VM before Patching Task Sequence – PowerCLI

A while ago I mentioned in a post about creating a bespoke patching task sequence for a client who wanted to snap shot every VM before patching. To do this I created a silent install wrapper for PowerCLI using PowerShell.

Anyway, as per the request… here is the script I used to snapshot a VM before patching it during the Task sequence. It must be run as a command line step and using an account that has access to VSphere.
 

Copyright 2016 SCCMOG | All Rights Reserved