I am trying to uninstall an application from the 50 windows machine and was thinking to run the uninstallation script through group policy but need help where my script can get the hostname automatically when it runs on the machine.
Asked
Active
Viewed 586 times
-3
-
`echo %USERDOMAIN%` – Gerhard Dec 16 '20 at 05:20
-
4Does this answer your question? [How do I get the localhost name in PowerShell?](https://stackoverflow.com/questions/1169891/how-do-i-get-the-localhost-name-in-powershell) – Dabombber Dec 16 '20 at 05:28
1 Answers
0
PowerShell:
$env:COMPUTERNAME
or
[Environment]::MachineName
or
hostname
or
[System.Net.Dns]::GetHostName()
or
Get-WmiObject Win32_ComputerSystem | Select-Object -ExpandProperty Name
or
Get-CimInstance CIM_ComputerSystem | Select-Object -ExpandProperty Name
CMD:
hostname
or
echo %COMPUTERNAME%

stackprotector
- 10,498
- 4
- 35
- 64