Hi all,
I am trying to rename a computer with PowerShell. The script seems to work find when using a workgroup computer, but does not rename a member of a domain.
I am doing:
$ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem -Authentication 6
Write-Host "This computer is a member of a domain, and a domain administrator username and password is required"
$domainUsername = Read-Host "Please enter the domain administrator username (in the form DOMAIN\username or username@domain.com"
$domainPassword = Read-Host "Please enter the domain administrator password"
Write-Host "Renaming machine to $newSrvName (member of a domain) ..."
$renameReturn = $ComputerInfo.Rename($newS
rvName,$do
mainPasswo
rd,$domain
Username)
However, it is returning error code 1356 (I think that was it from memory) (i.e. $renameReturn = 1356) rather than zero. Renaming from Computer properities is possible with the same credentials.
I think 1356 relates to:
1355 The specified domain either does not exist or could not be contacted.
From:
http://www.hiteksoftware.com/knowledge/articles/049.htm
Any help much appreciated.
Regards,
Ben
http://social.technet.microsoft.com/Forums/en/winserverpowershell/thread/ad181fe8-dc87-46dd-8ebf-7b1beb0de30d
Solution:
OK, changed script to use:
$creds = Get-Credential
$renameReturn = $ComputerInfo.Rename($newS
Worked a treat :-) (This script renames a SP server). Only thing is now I guess the machine will also need a new SID still as multiple machines from the same template will exist in the same domain.