-3

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.

1 Answers1

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