Skip to content

Instantly share code, notes, and snippets.

@numbnet
Created May 1, 2021 17:40
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 numbnet/f11da93978d2f0a30450cf43fcb2e27a to your computer and use it in GitHub Desktop.
Save numbnet/f11da93978d2f0a30450cf43fcb2e27a to your computer and use it in GitHub Desktop.
Rename Computer
$NEWCOMPUTERNAME = MyPC;
echo "This PC Name - $env:COMPUTERNAME";
if ($env:ComputerName -in $NEWCOMPUTERNAME) {
echo "
This is Computer - $env:COMPUTERNAME
========================================
";
exit
} else {
echo "Rename this Computer?"; pause; Rename-Computer -NewName $NEWCOMPUTERNAME -Force;
echo "Restart Computer? "; pause; Restart-Computer -Force -Confirm;
}
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment