Renaming and Rebooting a Computer with PowerShell
Some things are just very easy in PowerShell. It's great!
Here is a true quickie - rename and reboot a computer system (including a remote computer!):
function renameAndReboot([string]$computer, [string]$newname)
$comp = gwmi win32_computersystem -computer $computer
$os = gwmi win32_operatingsystem -computer $computer
Voila! All done.