Skip to content

Instantly share code, notes, and snippets.

@bundyfx
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bundyfx/22aae897c286895de39a to your computer and use it in GitHub Desktop.
Save bundyfx/22aae897c286895de39a to your computer and use it in GitHub Desktop.
rename machine to IP address
$ip=((gwmi Win32_NetworkAdapterConfiguration | ? { $_.IPAddress -ne $null }).ipaddress | select -First 1)
$ipAddressName = $ip.Replace(".","-")
If ($env:COMPUTERNAME -eq $ipAddressName) {
Write-Host "$ipAddressName No need to change"
}
Else {
Rename-Computer -NewName $ipAddressName -Restart
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment