Skip to content

Instantly share code, notes, and snippets.

@Computer-Tsu
Last active October 21, 2025 13:18
Show Gist options
  • Save Computer-Tsu/6f60ca5c38169d262e155fb10ccc3062 to your computer and use it in GitHub Desktop.
Save Computer-Tsu/6f60ca5c38169d262e155fb10ccc3062 to your computer and use it in GitHub Desktop.
Working with UUID, GUID, MAC addresses

UUID and GUID

IT techs that use imaging/deployment and/or DHCP/PXE will often be working with a computer's GUID, UUID, or MAC address. For example, you have received a shipment of new desktops and are preloading your Windows Active Directory with the new computer names in the desired OU. You will then be ready to boot them and have the new computers network PXE and start installing your company base image. The packaging gives you the UUID but you need to provide the GUID to the computer proerties in AD.

Some tools to help convert back and forth between the different formats.

Example:
WFLGNVLAB01
UUID: 457A9480-E7BE-11E2-9C6A-8851FB69DFA3
GUID: 80947A45-BEE7-E211-9C6A-8851FB69DFA3
MAC address: 8851FB69DFA3

The hexadecimal pairs in each of the first three segments reverse order when converting and the last 12 characters (6 pairs) are the MAC address.


Get PC info from command line

C:\WINDOWS\System32\Wbem\wmic.exe csproduct get uuid C:\windows\system32\GetMac.exe C:\windows\system32\IPConfig /All wmic CSProduct get *

`` C:\Users\Administrator\Desktop\Sample_RIS_Scripts>cscript GetRISBIOSInfo.vbs /command:getuuid Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

12:17:45 PM: Connected with Winmgmts on "\WFLGNVLAB02" and accessing computer system. . . Success retrieving system UUID: C99A8E0E-0209-11DF-BBDA-FECC8F92000A ``


Entering into Tools

Application Format Entered as
ADUC (AD Users & Computers MMC) guid, no dashes
DHCP (reservation) mac, no symbols

LDAP Search query in AD
(&(objectClass=computer)(netbootGuid=\80\94\7A\45\BE\E7\E2\11\9C\6A\88\51\FB\69\DF\A3)) WFLGNVLAB01

#Convert a UUID to GUID, batch file needs double percent
setlocal enabledelayedexpansion
set "UUID=457A9480-E7BE-11E2-9C6A-8851FB69DF3A"
set "UUID=%UUID:-=%
echo %UUID%
set "GUID=%UUID:~6,2%%UUID:~4,2%%UUID:~2,2%%UUID:~0,2%-%UUID:~10,2%%UUID:~8,2%-%UUID:~14,2%%UUID:~12,2%-%UUID:~16,4%-%UUID:~20,12%"
echo %GUID%
echo %UUID%
function Convert-UUIDToGUID {
param (
[string]$UUID
)
# Remove dashes from UUID
$uuid = $UUID -replace '-', ''
# Rearrange the parts to form GUID
$guid = '{0}{1}{2}{3}{4}' -f ($uuid.Substring(6, 2) + $uuid.Substring(4, 2) + $uuid.Substring(2, 2) + $uuid.Substring(0, 2)),
($uuid.Substring(10, 2) + $uuid.Substring(8, 2)),
($uuid.Substring(14, 2) + $uuid.Substring(12, 2)),
$uuid.Substring(16, 4),
$uuid.Substring(20, 12)
# Alternate format use {0}-{1}-{2}-{3}-{4}
return $guid.ToUpper()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment