Script Repository

Convert MAC address to Netboot-GUID

February 18, 2021

This script takes a MAC address of a computer stored in Adaxes custom attribute CustomAttributeText1 and saves it to the Netboot-GUID attribute in the binary form.

To be able convert a MAC address, you need to create a business rule triggered after creating or updating a computer account that will run the script. Sample business rule to run the script after updating a computer:

Edit Remove
# Get MAC address
$mac = $Context.GetModifiedPropertyValue("adm-CustomAttributeText1")

# If the MAC address is empty, exit
if ([System.String]::IsNullOrEmpty($mac))

# Build GUID in string format
$guidString = "00000000-0000-0000-0000-$mac"

# Convert to a GUID object
    $guid = New-Object "System.Guid" $guidString
    $Context.Cancel("The value entered for the Netboot-GUID property is invalid. Cannot convert '$guidString' into a valid GUID")

# Save changes
$Context.SetModifiedPropertyValue("netbootGUID", $guid.ToByteArray())

# Clear the custom attribute
$Context.SetModifiedPropertyValue("adm-CustomAttributeText1", $NULL)

Comments ( 0 )
No results found.
Leave a comment