Set Surface Asset Tag During a Configuration Manager Task Sequence


Update 12/1/2015: Script updated to version 1.1 to add support for Surface Pro 4, Surface 3, and SurfaceBook

The August 2014 firmware update for the Surface Pro 3 now allows you to set an asset tag field in the UEFI firmware. Many companies like to have this field set and sometimes use the asset tag to name computers during imaging.

The September 2015 firmware update adds support for the AssetTag field in the Surface 3.

You set the asset tag in UEFI by running an executable (AssetTag.exe - Surface Pro 3 Asset Tag CLI Utility) with the –s parameter followed by the characters you want to set the asset tag to. The asset tag can be up to 36 characters long. Valid characters include A-Z, a-z, 0-9, period and hyphen.

You can run the AssetTag.exe tool in WinPE or in the Full OS. I’ve created a script that will help ensure the asset tag is set during a task sequence if it’s not already. You will probably want to set this after the “Partition Disk 0 – UEFI” step to ensure you get prompted for the asset tag early in the task sequence.

This is using a "Run Command Line" step referencing a package contains the script files available for download below.

You will also want to ensure the step for the script only runs if the model is contains Surface

Here's the syntax for the WMI Query: select * from win32_computersystem where model like "%Surface%"

What The Script Does:

  1. Gets the SMBIOSAssetTag property from the win32_systemenclosure class. The SMBIOSAssetTag property is where the asset tag from the firmware is stored in WMI.
  2. If the SMBIOSAssetTag is equal to 0, that means the asset tag has not been set in the UEFI firmware. If the SMBIOSAssetTag is anything other than 0, the script won’t do anything unless you enable step 5 that sets the hostname to the asset tag.
  3. If the asset tag is 0, the script will hide the current task sequence process dialog and prompt the user to enter an asset tag.
  4. Error handling:
    1. Outdated Firmware: I added some logic to detect if the current firmware version does not support setting the asset tag. If the firmware needs to be updated, the AssetTag.exe tool will fail with error code 775. If this happens, the script will show a message box that says “You need to apply the latest UEFI firmware update to support setting the asset tag”. The script will then exit with error code 775 and the task sequence will fail if continue on error is not checked. You can create a USB drive to update the firmware based in this post or update the firmware using Windows Update.
    2. Other Errors: Any other error code returned from the AssetTool.exe will show a message box “Failed to set the asset tag: valid characters include A-Z, a-z, 0-9, period and hyphen. Error code: (X)”. The script will fail with exit code the AssetTool.exe returned and the task sequence will fail if continue on error is not checked.
  5. Optional Set Computer Name:   You can remove the comment from line 44 to have the script set the OSDComputerName task sequence variable to whatever the user entered into the dialog prompt. Note: This current version has no logic to ensure the input is less than 15 characters and contains valid characters for a hostname.

Files Included in The Download:

The script is a VBScript and pretty straight forward. The following files are included in the zip below:

  • SurfaceAssetTag.vbs (This is the actual script. Run wscript.exe SurfacePro3AssetTag.vbs in a run command step the package that has all these files)
  • AssetTag.exe (The tool the actually sets the asset tag in the firmware. The AssetTag.exe included in the zip below was dated 9/25/14 you may want to check for a newer version here before running the script)
  • Surface Pro 3 Asset Tag README.txt (A readme file from the download)

Click Here To Download The Script

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of any included script samples are subject to the terms specified in the Terms of Use