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:
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)