Making computer name use last 6 of MAC address?

In my mid level task, I'm running setcomputername_x64.exe /log /name:COMP-$FormFactor-$Mac.

This outputs a computer name of COMP-D-000312. (Where this is the first X numbers of MAC up to the 15 max )

How do I get this output to be COMP-D-LAST6ofMAC?

0 Comments   [ + ] Show comments

Answers (3)

Posted by: JordanNolan 3 weeks ago
10th Degree Black Belt

I usually only use the Get/Set when I want to specifically name a computer. If you have a naming scheme in mind based on the hardware of the computer, like the last six of the MAC, then you do not need Get/Set Computername.  You can just use Powershell to rename the computer at any point before it joins the domain (if you have that scripted):

This assumes the computer only has 1 hardware NIC plugged:

$MyMac = Get-NetAdapter |Where-Object {$_.PhysicalMediaType -eq "802.3" -and $_.Status -eq "Connected"} | Select MacAddress
$LastSix = $MyMac.MacAddress.SubString(9,8) -replace '[-]'
$MyName = "Comp-" + $LastSix
Rename-Computer -ComputerName $MyName

I am not sure what Get/Set uses for the Formfactor but the powershell is:

Function Get-ChassisType() {

  $ChassisTypes = @{

    Name = 'ChassisType'

    Expression = {

      # property is an array, so process all values

      $result = foreach($value in $_.ChassisTypes)




          1          {'Other'}

          2          {'Unknown'}

          3          {'Desktop'}

          4          {'Low Profile Desktop'}

          5          {'Pizza Box'}

          6          {'Mini Tower'}

          7          {'Tower'}

          8          {'Portable'}

          9          {'Laptop'}

          10         {'Notebook'}

          11         {'Hand Held'}

          12         {'Docking Station'}

          13         {'All in One'}

          14         {'Sub Notebook'}

          15         {'Space-Saving'}

          16         {'Lunch Box'}

          17         {'Main System Chassis'}

          18         {'Expansion Chassis'}

          19         {'SubChassis'}

          20         {'Bus Expansion Chassis'}

          21         {'Peripheral Chassis'}

          22         {'Storage Chassis'}

          23         {'Rack Mount Chassis'}

  24         {'Sealed-Case PC'}

  25         {'Multi-system chassis'}

  26         {'Compact PCI'}

  27         {'Advanced TCA'}

  28         {'Blade'}

  29         {'Blade Enclosure'}

  30         {'Tablet'}

  31         {'Convertible'}

  32         {'Detachable'}

  33         {'IoT Gateway'}

  34         {'Embedded PC'}

  35         {'Mini PC'}

  36         {'Stick PC'}

          default    {"$value"}






  return (Get-CimInstance -ClassName Win32_SystemEnclosure | Select-Object -Property $ChassisTypes).ChassisType



  • Running your above code gives me the following error:

    You cannot call a method on a null-valued expression.
    At line:1 char:1
    + $MyMac = Get-NetAdapter |Where-Object {$_.PhysicalMediaType -eq "802. ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Execution Policy is set to unrestricted.
    Any ideas? - computeguy12119 2 weeks ago
    • This ended up getting me there. Thank you for getting me in the right area!

      $MyMac = Get-NetAdapter |Where-Object {$_.PhysicalMediaType -eq "802.3" -and $_.Status -eq "Connected"} | Select MacAddress
      $LastSix = (Get-NetAdapter).MacAddress.Replace('-','').Substring(6,6)
      $MyName = "Comp-" + $LastSix
      Rename-Computer -NewName "$MyName" -Restart - computeguy12119 2 weeks ago
Posted by: ChorreraTownTech 3 weeks ago
White Belt

Hi, unfortunately I can't think on any 'easy' way to accomplish that. I would try using the method of a data file as described below or contacting PSO so they can build a custom script for you. You can reach them at remoteconfig@quest.com

-------------------------- Set Computer Name for use with a data file --------------------------

The “/rdf:” and “/dfk:” flags allow Set Computer Name to look in a text file for the new computer name. This allows you to build up a data file that maps devices to their names. The most popular variables to use as identifiers are MAC address ($Mac) & Serial Number ($Serial)

To create the data file, you will need to create a text file and list the entries in the following format:

identifier = desiredcomputername

Here’s an example with MAC addresses:

00508B052AE8 = Computer1

005056C00008 = Computer2 

005056C00001 = Computer3 

Once complete, zip up the text file along with the appropriate setcomputername executable, 32bit or 64bit.

To create this task:

1. Go to Library --> Postinstallation Tasks.

2. From the "choose action..." drop-down menu

3. Select Add New Application...

4. Give the task a name, such as "Set Computer Name x86"

1. Select the K2000 Boot Environment (Windows) as the runtime environment

2. Click on Upload to select the zip file you created with the data file and setcomputername executable.

3. Type the following in the command line field: setcomputername.exe /rdf:Nameofdatafile /dfk:$Variable

 (Note: If you would like to get messages from the script as to what it is doing add the flag "/debug" or add the “/log” flag to generate a log file (both flags are used without the quotes)

5. Save the Postinstallation Task

Usage Examples:

setcomputername.exe /rdf:computernames.txt /dfk:$Serial will search the computernames.txt file for the serial number of the current system and set the computer name to the associated name if it finds the serial number in computernames.txt

setcomputername.exe /rdf:computernames.txt /dfk:$Mac will search the computernames.txt file for the MAC address of the current system and set the computer name to the associated name if it finds the MAC in computernames.txt

Posted by: gwir 1 week ago
Second Degree Brown Belt


There is a variable called MAC_ADDRESS when you boot in your KBE, you can do something like :


Then use this variable with your favotite tool to set the computer name.

This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ