G'day all
I've got 98 users that I need to change their profile paths in AD.
I've got the following from the code examples
script start
Set objUser = GetObject
("LDAP://cn=SteveVai,ou=People,dc=Workplace,dc=com")
objUser.Put "profilePath", "\\server5\Profiles$\VaiS"
objUser.SetInfo
script finish
which I'm assuming should make the change for me but how do I arrange the
script to
take the input from a textfile full of the users names etc?

Thanks
Mark

Re: Newbie script help PLEASE. Scripting AD users profile path changes. by Slim

Slim
Wed Apr 12 08:23:12 CDT 2006

look up Scripting.FileSystemObject

easy to use


as for getting the distinguished name, from the user name

replace Domain,dc=com in ccode below, it should then work




dim dUser:dUser = InputBox("User Name","ThatsIT")
dim oUser:set oUser = GetObject("LDAP://"& getUserDN( dUser) )

objUser.Put "profilePath", "\\server5\Profiles$\VaiS"
objUser.SetInfo

function getUserDN(userName)
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 10
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT distinguishedName FROM 'LDAP://dc=Domain,dc=com' WHERE
objectCategory='user' " & _
"AND sAMAccountName='"& userName &"'"
Set objRecordSet = objCommand.Execute
dim ans
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
ans = objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
getUserDN = ans
end function















"Clubsprint" <spamspamspamspam@nospam.com> wrote in message
news:e1i4lf$t91$1@news-01.bur.connect.com.au...
> G'day all
> I've got 98 users that I need to change their profile paths in AD.
> I've got the following from the code examples
> script start
> Set objUser = GetObject
> ("LDAP://cn=SteveVai,ou=People,dc=Workplace,dc=com")
> objUser.Put "profilePath", "\\server5\Profiles$\VaiS"
> objUser.SetInfo
> script finish
> which I'm assuming should make the change for me but how do I arrange the
> script to
> take the input from a textfile full of the users names etc?
>
> Thanks
> Mark
>
>
>