This script is used within the SCCM task sequence and performs two functions.  Firstly it determines whether or not the machine is a Hyper-V VM, and if it is, it assigns a task sequence variable called “PSisVM”.  This is useful to hold in the TS as there are certain things that only need to be done on laptops and not VMs (such as Bitlocker, TPM etc).

Secondly, it assigns the “OSDComputerName” TS variable which SCCM will use to name the machine.  It does this by taking the dell service tag number, along with a sitecode and applying a ‘D’ for desktops or ‘L’ for laptops at the end.  It also has a failsafe in there if no serial number is picked up, so that the TS will succeed and the machine will get a unique name.

There is also extensive logging throughout to help with troubleshooting if the TS fails.

Much of the logging part of the script was ‘borrowed’ from scripts over at so thank you to them 👍🏼

You can see the detailed Task Sequence steps in this post.