Last active
November 16, 2015 17:52
-
-
Save nitrocode/845c55c84152ede8683f to your computer and use it in GitHub Desktop.
Powershell 2 script to change the hostname
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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