Skip to content

Instantly share code, notes, and snippets.

@nitrocode
Last active November 16, 2015 17:52
Show Gist options
  • Save nitrocode/845c55c84152ede8683f to your computer and use it in GitHub Desktop.
Save nitrocode/845c55c84152ede8683f to your computer and use it in GitHub Desktop.
Powershell 2 script to change the hostname
# Usage: powershell -File SetHostname.ps1 -name "Terminator"
# Works on Windows 7 64bit
# Requires restart for changes to take effect
# get params
param (
[string]$name = "Dev"
)
Write-Host "Server: $name"
# change hostname
$ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem
$ComputerInfo.Rename($name)
Restart-Computer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment