Skip to content

Instantly share code, notes, and snippets.

@ZJPat
Created November 4, 2015 06:11
Show Gist options
  • Select an option

  • Save ZJPat/6a19aeb762b45bc5ce1d to your computer and use it in GitHub Desktop.

Select an option

Save ZJPat/6a19aeb762b45bc5ce1d to your computer and use it in GitHub Desktop.
function Set-ComputerName {
param( [switch]$help,
[string]$CurrentPCName=$(read-host "Please specify the current name of the computer"),
[string]$computerName=$(read-host "Please specify the new name of the computer"))
$usage = "set-ComputerName -CurrentPCname CurrentName -computername AnewName"
if ($help) {Write-Host $usage;break}
$computer = Get-WmiObject Win32_ComputerSystem -CurrentPCname CurrentName -computername $currentPCName
$computer.Rename($computerName)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment