View Single Post
Beerman462
Member
(08-02-2017, 11:08 PM)
Beerman462's Avatar
Scripting question. I used this script twice to rename PC on two different domains no issue.

Now I am in the same domain as my first rename
job and this is what I get.

Rename-Computer : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'ComputerName'. Specified method is not supported.
At C:scriptsOldNew.ps1:6 char:31
+ Rename-Computer -ComputerName $computers.Oldname -NewName $computers. ...


Script

$DomainCredential = Get-Credential
$computers = import-csv -Path "c:scriptscomputers.csv"

foreach ($oldname in $computers)
{
Rename-Computer -ComputerName $computers.oldname -NewName $computers.newname -DomainCredential $DomainCredential -Force -Restart
}


CSV content

oldname,newname
KTP-Helpdesk,SUPPORT3
cbeers1,SUPPORT2