Rilevare il nome di una macchina

()

Per rilevare il nome macchina (hostname) in ambiente Windows, puoi utilizzare diversi strumenti a seconda del contesto (prompt, PowerShell, GUI). Ecco una panoramica completa per SysAdmin:


1. Dal Prompt dei comandi (CMD / DOS)

cmd
hostname

Restituisce solo il nome del computer locale.


2. Con echo e variabili di sistema

cmd
echo %COMPUTERNAME%

Equivalente a hostname, ma utile negli script batch.


3. Con PowerShell

powershell
$env:COMPUTERNAME

oppure:
powershell
(Get-WmiObject Win32_ComputerSystem).Name

Più flessibile e usabile anche in script di rete.


4. Rilevare il nome macchina remoto (con hostname noto o IP)

cmd
nbtstat -A 192.168.1.10

oppure con PowerShell:
powershell
[System.Net.Dns]::GetHostEntry("192.168.1.10")

Restituisce il NetBIOS name o FQDN se risolto correttamente.


5. In GUI (interfaccia grafica)

  • Tasto destro su Questo PCProprietà
  • Oppure: sysdm.cpl → Tab Nome computer

6. Per rilevare tutti i nomi in una rete (avanzato)

powershell
Get-ADComputer -Filter * -Property Name | Select-Object Name

Richiede modulo Active Directory (RSAT) e privilegi adeguati.


Best Practice per SysAdmin

  • Usa $env:COMPUTERNAME nei tuoi script PowerShell per log, report e alert automatici.
  • Verifica DNS e NetBIOS se non risolvi i nomi remoti.
  • Evita hostname duplicati in rete (problemi DHCP/AD).

/ 5
Grazie per aver votato!

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?