PoshCode Archive  Artifact Content

Artifact 421232f6f3ca252a10a5017133e9154c9af5a59f1b3270d8996947ee10e2ea98:

  • File Set-Computername.ps1 — part of check-in [35cb78fbd2] at 2018-06-10 13:03:49 on branch trunk — A function to rename a computer (user: Andy Schneider size: 648)

# encoding: ascii
# api: powershell
# title: Set-Computername
# description: A function to rename a computer
# version: 0.1
# type: function
# author: Andy Schneider
# license: CC0
# function: Set-ComputerName
# x-poshcode-id: 1997
# x-archived: 2010-07-21T21:16:26
#
# Andy Schneider
# get-powershell.com
#
function Set-ComputerName {
	param(	[switch]$help,
		[string]$computerName=$(read-host "Please specify the new name of the computer"))
			
	$usage = "set-ComputerName -computername AnewName"
	if ($help) {Write-Host $usage;break}
	
	$computer = Get-WmiObject Win32_ComputerSystem
	$computer.Rename($computerName)
	}