Skip to content

Instantly share code, notes, and snippets.

@PSingletary
Created February 28, 2018 13:27
Show Gist options
  • Select an option

  • Save PSingletary/669d40f0b91ae3c79ec0903893a44be1 to your computer and use it in GitHub Desktop.

Select an option

Save PSingletary/669d40f0b91ae3c79ec0903893a44be1 to your computer and use it in GitHub Desktop.
$Credential = Get-Credential -Message User: username@DOMAIN or Domain\Username
While ($true){
write-host ""
$OldComputerName = Read-Host "What is the old computer name?"
$NewComputerName = Read-Host "What is the new computer name?"
$Restart = Read-Host "Restart the computer? Y for yes or N for no."
if ($Restart -eq "Y"){
Rename-Computer -ComputerName $OldComputerName -NewName $NewComputerName -Restart -Force -DomainCredential $Credential -verbose
}
if ($Restart -ne "Y"){
Rename-Computer -ComputerName $OldComputerName -NewName $NewComputerName -Force -DomainCredential $Credential -verbose
}
}$Credential = Get-Credential -Message User: username@DOMAIN or Domain\Username
While ($true){
write-host ""
$OldComputerName = Read-Host "What is the old computer name?"
$NewComputerName = Read-Host "What is the new computer name?"
$Restart = Read-Host "Restart the computer? Y for yes or N for no."
if ($Restart -eq "Y"){
Rename-Computer -ComputerName $OldComputerName -NewName $NewComputerName -Restart -Force -DomainCredential $Credential -verbose
}
if ($Restart -ne "Y"){
Rename-Computer -ComputerName $OldComputerName -NewName $NewComputerName -Force -DomainCredential $Credential -verbose
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment