George2 George2 - 1 year ago 104
PowerShell Question

How do I get the localhost name in PowerShell?

How do I get the localhost (machine) name in PowerShell? I am using PowerShell 1.0.

Answer Source

You can just use the .NET Framework method:

[System.Net.Dns]::GetHostName()

also

$env:COMPUTERNAME