We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script Repository

Convert MAC address to Netboot-GUID

February 18, 2021 Views: 3381

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
Leave a comment
Loading...

Got questions?

Support Questions & Answers