Torgeir
Wed Sep 17 13:28:00 CDT 2003
Henrik Alstersjo wrote:
> I would like to change the name of severel but not all
> users in a lot of windows 2000 servers. Does anybody know
> how to do this with scripting. Or any other way as well?
Hi
Script below renames local users on a computer (local or remote), using ADSI
from a vbscript.
' code start
sOldUser = "Administrator"
sNewUser = "RenamedAdmin"
sComputerName = "SomeComputer"
' If you want to do this on the local computer, enable the following lines
' to get computer name for local computer
'Set oWshNet = CreateObject("WScript.Network")
'sComputerName = oWshNet.ComputerName
Set oComputer = GetObject("WinNT://" & sComputerName)
' Turn off error handling in case sOldUser does not exist
On Error Resume Next
Set oUser = GetObject("WinNT://" & sComputerName & "/" & sOldUser & ",user")
Set oNewUser = oComputer.MoveHere(oUser.ADsPath, sNewUser)
On Error Goto 0
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide:
http://www.microsoft.com/technet/scriptcenter