Difference between DNSHostName and Name in WMI ComputerSystem properties

583 Views Asked by At

These 2 properties appear to be set to the same values on a standard Windows domain environment. Can they be different? How can they be set to different values?

e.g.

$computer = Get-WMIObject Win32_ComputerSystem
$computer.Name
$computer.DNSHostName
2

There are 2 best solutions below

6
On

They appear to be different properties, though presumably they will have the same value. Win32_ComputerSystem Doc

DNSHostName:

  • Data type: string
  • Access type: Read-only
  • Qualifiers: MappingStrings ("Win32API|GetComputerNameEx|ComputerNameDnsHostname")
  • Name of local computer according to the domain name server (DNS).

Name:

  • Data type: string
  • Access type: Read-only
  • Qualifiers: Key
  • Key of a CIM_System instance in an enterprise environment.
  • This property is inherited from CIM_ManagedSystemElement.

Document states both properties are read-only. Get-Member suggests they are set-able, but I'd be skeptical.

0
On

One difference is that 'Name' is limited by 15 chars (it works like GetComputerName() win32 API), while 'DNSHostName' is not (it works like GetComputerNameEx(ComputerNameDnsHostname) win32 API).

So 'Name' will contain truncated Computer Name if its length > 15 chars; but 'DNSHostName' will contain full Computer Name