SturmUndDrang
SturmUndDrang

Reputation: 1966

Difference between DNSHostName and Name in WMI ComputerSystem properties

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

Upvotes: 1

Views: 760

Answers (2)

Maximus
Maximus

Reputation: 11

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

Upvotes: 1

Steven
Steven

Reputation: 7087

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.

Upvotes: 0

Related Questions