PoshCode Archive  Artifact [a39b8bebb9]

Artifact a39b8bebb9e66e5b90dc183ddfb961a23aee6b126b5da1d46262dc3b980b140f:

  • File DT.ps1 — part of check-in [397f224ac0] at 2018-06-10 13:40:29 on branch trunk — A function to rename a computer (user: JesusBorbolla size: 981)

# encoding: ascii
# api: powershell
# title: DT
# description: A function to rename a computer
# version: 0.1
# type: function
# author: JesusBorbolla
# license: CC0
# function: Set-ComputerName
# x-poshcode-id: 4411
# x-archived: 2013-08-23T12:51:43
# x-published: 2013-08-20T22:02:00
#
# Andy Schneider
# get-powershell.com
# Add capability to change name on remote PC and Update Usage statement
# Gerald Klassen
#
function Set-ComputerName {Intelligent Analysis Inc
	param(	[switch]$help,
		[string]$originalPCName=$(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 -originalPCname CurrentName -computername AnewName"
	if ($help) {Write-Host $usage;break}
	
	$computer = Get-WmiObject Win32_ComputerSystem -OriginalPCname OriginalName -computername $originalPCName
	$computer.Rename($computerName)
	}Jay Intelligent Inc