Another option is to prefix the value with 0x and cast it to an int64:
$Next_MAC_Address = ([int64]"0x$Last_MAC_Address"+1).ToString('X12')
You could also use the format operator (-f) instead of the ToString() method:
$Next_MAC_Address = '{0:X12}' -f ([int64]"0x$Last_MAC_Address"+1)
There is, however, one thing that may be worth noting. MAC addresses aren't just random 6-byte numbers without any inner structure. They actually consist of two parts. The first 3 bytes form the Organizationally Unique Identifier (OUI), a vendor-specific prefix (00-15-5D is one of the OUIs belonging to Microsoft). Only the last 3 bytes are a random number, a unique identifier for each card from the vendor identified by the OUI.
Taking that into consideration you may want to split the MAC address accordingly, e.g. like this:
$oui, $nid = $Last_MAC_Address -split '(?<=^[0-9a-f]{6})(?=[0-9a-f]{6}$)'
or like this:
$oui = $Last_MAC_Address.Substring(0, 6)
$nid = $Last_MAC_Address.Substring(6, 6)
and increment only the NIC identifier, and only if it wouldn't overflow:
if ($nid -ne 'ffffff') {
$Next_MAC_Address = "{0}{1:X6}" -f $oui, ([int64]"0x$nid"+1)
} else {
Write-Error 'MAC address overflow.'
}
([Int64]::Parse('00155DE10B73', 'HexNumber') + 1).ToString('X12')("Good to know." | Format-Hex).Bytes.ForEach{[char]$_} -join ''Hexadecimal:("Good to know." | Format-Hex).HexBytes.Split(' ').ForEach{[char][int]::Parse($_,'HexNumber')} -join ''Try:("Good to know." | Format-Hex).<ctrl>+<space> to know more...'E476F6F6420746F206B6E6F772'.ToCharArray().ForEach{if($null -eq $HxSplt){$HxSplt = $_}else{"$HxSplt$_"; $HxSplt=$null}}