• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

FQDN and hostname

On WIndows 2008 I perform the following:

c:\>hostname
cont6

Open in new window


What I actually need is the fully qualified host name

How can I get that , what command should I run
0
Anthony Lucia
Asked:
Anthony Lucia
2 Solutions
 
MazdajaiCommented:
Try the following in powershell

$env:computername.$env:userdnsdomain

Open in new window

0
 
becraigCommented:
The above would give you the users domain and not necessarily the computer domain.

(gwmi WIN32_ComputerSystem).Domain

This is based on the fact that a user might be in a separate domain to the domain a computer is in .
0
 
Anthony LuciaAuthor Commented:
I performed th efollowing within PowerShell

Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\benchmarking> $env:computername.$env:userdnsdomain
PS C:\Users\benchmarking>
PS C:\Users\benchmarking>
PS C:\Users\benchmarking>
PS C:\Users\benchmarking> $env:computername.$env:userdnsdomain
PS C:\Users\benchmarking>
PS C:\Users\benchmarking>
PS C:\Users\benchmarking>

Open in new window



but did not get the domain
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
becraigCommented:
Run the command I provided:
(gwmi WIN32_ComputerSystem).Domain  from a powershell window, it should give you the domain of the computer.
0
 
MazdajaiCommented:
Is the pc a domain member?

If the computer in the workgroup it will display a blank line.
0
 
David Johnson, CD, MVPOwnerCommented:
(gwmi WIN32_ComputerSystem).Name + "." + (gwmi WIN32_ComputerSystem).Domain

Will return the fqdn of the computer
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now