Saturday, August 01, 2015

PowerShell Quick Tips: Rename a computer

Rename local computer to W8M1 and restart
PS D:\> Rename-Computer -NewName W8M1 -Restart
The above command works with Powershell 3.0. For Powershell 2.0, below can be used on an elevated privileges.
PS D:\> $computer = Get-WmiObject Win32_ComputerSystem -ComputerName <old_name>
PS D:\> $computer.Rename("<new_name>")
PS D:\> $os = Get-WmiObject Win32_OperatingSystem
PS D:\> $os.psbase.Scope.Options.EnablePrivileges = $true
PS D:\> $os.Reboot()

Using WMIC to rename a computer
D:\> WMIC ComputerSystem where Name="%computername%" call Rename Name=NewName

References:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/c9dcf26a-5476-4199-8311-b101c969a47a/
http://blogs.technet.com/b/askds/archive/2009/02/19/renaming-a-computer-using-wmic-and-how-to-get-around-that-aggravating-invalid-global-switch-error.aspx

No comments:

Fedora install screen chronicle

Fedora install screen chronicle Below are links to Fedora installation screens. It is interesting to see how it has evolved over time. Fe...