A hostname is a unique identifier that is assigned to a device (host) which connected to the network. It allows to differentiate one device from another on a specific network. This tutorial shows 2 methods to get hostname on Windows.
Method 1 - CMD
On Windows, the
hostname command can be used for displaying hostname. Run command without any arguments:
Method 2 - PowerShell
hostname command can be used in PowerShell as well. There are another way. The
System.Net.DNS class provides
GetHostName method to get hostname.