Markdmac
My environment is a very small percentage of our machines are domain, the rest of them are workgroup for the time being. Slowly we are bringing them over to an AD domain. Therefore, I didn't go with the LDAP route. As I understand it, you can't use LDAP to connect to a particular machine.
After doing some searching, I did find this
rename administrator
thread329-585172
I altered it, but would like some explanation if you don't mind. The current itertaion is as follows
'On Error Resume Next
strcomputer = wscript.Arguments (0)
Dim objWshShell, objFSO
'Initiliase a few useful bits...
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Rename Test account and set a few attributes
RenameUser strComputer,"test","test2","Test renamed Test2"
Msgbox "Test Account renamed"
'****************************************************************************************
'Functions and Subs below here...
'****************************************************************************************
Sub RenameUser(strDomain,strOldUsername,strNewUsername,strDescription)
Dim objComputer, objUser, objMoveUser
Set objComputer = GetObject("WinNT://" & strDomain)
Set objUser = GetObject("WinNT://" & strDomain & "/" & strOldUsername & ",user")
objUser.FullName = strDescription
objUser.Description = strDescription
objUser.SetInfo
Set objMoveUser = objComputer.MoveHere(objUser.ADsPath, strNewUsername)
Set objComputer = nothing
Set objUser = nothing
Set objMoveUser = nothing
End Sub
'****************************************************************************************
I am sure the 2 Set lines in the can be removed/altered/cleaned up. But why is the objMoveUser line necessary for a rename? The script fails when I take it out.
Also, apparently I am ok, substituting strComputer for strDomain. Presumably, whatever computer I enter at the command line will be its own 'domain' so to speak?