Script Repository


Convert MAC address to Netboot-GUID

October 06, 2015
1726

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
PowerShell
# Get MAC address
$mac = $Context.GetModifiedPropertyValue("adm-CustomAttributeText1")

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

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

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

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

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


Comments ( 0 )
No results found.
Leave a comment