Write to a custom asset field (MAC Address for Ethernet)

Written By Mikel from Gorelo

You can write to a custom asset field via scripts. This is useful for things such as BitLocker keys, rotating local admin passwords and third-party UID’s.
​
In this example, we'll write the MAC Address for WOL use.

Step 1: Create the custom asset field

  1. Navigate to Settings -> Assets -> Custom Fields

  2. Add custom field with the following details

    • Name: MAC Address

    • Variable: macAddress

Step 2: Create the script

  1. Navigate to Scripts

  2. Create a script with the following details:

    • Name: MAC Address for Ethernet

    • Content:

Example
# Get Ethernet adapter MAC address only $MacAddress = (Get-NetAdapter | Where-Object {$_.Name -like "*Ethernet*" -and $_.Status -eq "Up"} | Select-Object -First 1 -ExpandProperty MacAddress) if ($MacAddress) { GoreloAction -SetCustomField -Name 'asset.macAddress' -Value $MacAddress Write-Host "Ethernet MAC Address set to: $MacAddress" } else { Write-Host "No active Ethernet adapter found" }

Step 3: Deploy the script via a policy

  1. Navigate to Policies

  2. Edit an existing policy that covers the assets you want to store the MAC Address for

  3. Add the 'MAC Address for Ethernet' script and set to repeat at your preferred interval

  4. Save and Distribute the policy