saddouki
asked on
Rename multiple domain PCs
I need a script to rename multiple domain computers. The script should be able to read from a text or excel file both old and new name
Thanks
Thanks
http://social.technet.microsoft.com/wiki/contents/articles/how-to-rename-computers-using-powershell-and-a-csv-file.aspx
Check this blog, Michael completed this activity using Excel:
http://dermeph.wordpress.com/2009/03/30/how-to-rename-multiple-computers-in-a-windows-domain/
http://dermeph.wordpress.com/2009/03/30/how-to-rename-multiple-computers-in-a-windows-domain/
ASKER
@ Govvy
I am not sure I understand your link script, I am kind of confused by the files names. First a csv files is mentioned then the systems names are saved under in "rename.txt", then another file is added to script $csvfile = "C:\temp\newname.txt" ?
Can you help me undestand ?
Thanks
I am not sure I understand your link script, I am kind of confused by the files names. First a csv files is mentioned then the systems names are saved under in "rename.txt", then another file is added to script $csvfile = "C:\temp\newname.txt" ?
Can you help me undestand ?
Thanks
Those two files should be the same name.
ASKER
Here what I have done"
1) Create a ps1 file as follow
$csvfile = "C:\temp\newname.txt"
Import-Csv $csvfile | foreach {
$oldName = $_.OldName;
$newName = $_.NewName;
Write-Host "Renaming computer from: $oldName to: $newName"
netdom renamecomputer $oldName /newName:$newName /uD:aaa\myusername /passwordD:* /force /reboot
}
2) Create a rename.txt
OldName,NewName
PC1,PC1N
PC2,PC2N
3)Saved both files in the same location
nothing happens and the .ps1 file opens automatically, what I am doing wrong ?
1) Create a ps1 file as follow
$csvfile = "C:\temp\newname.txt"
Import-Csv $csvfile | foreach {
$oldName = $_.OldName;
$newName = $_.NewName;
Write-Host "Renaming computer from: $oldName to: $newName"
netdom renamecomputer $oldName /newName:$newName /uD:aaa\myusername /passwordD:* /force /reboot
}
2) Create a rename.txt
OldName,NewName
PC1,PC1N
PC2,PC2N
3)Saved both files in the same location
nothing happens and the .ps1 file opens automatically, what I am doing wrong ?
Change this line: $csvfile = "C:\temp\newname.txt" to:
$csvfile = "C:\temp\rename.txt"
$csvfile = "C:\temp\rename.txt"
ASKER
I did, still the same thing
Did you replace this line with your domain credentials?
/uD:aaa\myusername /passwordD
/uD:aaa\myusername /passwordD
ASKER
yes :
/uD:MyDomName\mydomainusername /passwordD
/uD:MyDomName\mydomainusername
"the .ps1 file opens automatically"
Are you double clicking on the PS1 file to execute? .PS1 is associated with the editor by default, not to execute.
That could be all that's going on here.
Have you tried running the PS1 script from a PowerShell command line? You'll probably need to enable unsigned local script execution if this is your first go-round with PoSh (I'm just guessing it is).
Hope that helps!
Are you double clicking on the PS1 file to execute? .PS1 is associated with the editor by default, not to execute.
That could be all that's going on here.
Have you tried running the PS1 script from a PowerShell command line? You'll probably need to enable unsigned local script execution if this is your first go-round with PoSh (I'm just guessing it is).
Hope that helps!
ASKER
@ netjgrnaut
You got it :) but now I am getting "Invalid option 'renamecomputer' the syntax of this command is NETDOME [options] ..."
You got it :) but now I am getting "Invalid option 'renamecomputer' the syntax of this command is NETDOME [options] ..."
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.