RE: Terminal Services Profile Path Script
- From: DrBadvines <DrBadvines@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 31 Jul 2006 00:12:02 -0700
Hi,
Maybe you can use this script
It works for me
Set WshShell = WScript.CreateObject("WScript.Shell")
CurDir = WshShell.CurrentDirectory
' Enter your server/share value here, don't forget the trailing \
strRootDir = ""
SURE = MsgBox("This will modify all TS profile path ALL users" & vbcrlf &
"Execute modifications?", vbYesNo, "Sure?")
If SURE = 6 Then
'Do nothing but Continue
Elseif SURE = 7 Then
wscript.Quit
End If
Const ADS_SCOPE_SUBTREE = 2
strLOGFILE = CurDir & "\chgprofTS.log"
strERRORLOG = CurDir & "\chgprofTS-ERROR.log"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile (strLOGFILE, 8, True)
Set objErrorLog = objFSO.OpenTextFile (strERRORLOG, 8, True)
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, sAMAccountName FROM
'LDAP://dc=domein,dc=local' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
i = 0
e = 0
strinfomsg = "Script started at " & Now
objLogFile.WriteLine (strinfomsg)
objErrorLog.WriteLine (strinfomsg)
Do Until objRecordSet.EOF
i = i + 1
Wscript.Echo objRecordSet.Fields("distinguishedName").Value
Set objUser = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName"))
strOLD = objUser.TerminalServicesProfilePath
objUser.TerminalServicesProfilePath = strRootDir & objUser.samAccountName
objUser.SetInfo
if err.number <> 0 Then
e = e + 1
objErrorLog.WriteLine (objUser.samAccountName & vbTab & err.number)
err.clear
Else
objLogFile.WriteLine (objUser.samAccountName & vbTab & "modified from" &
vbTab & strOLD & vbTab & "to" & vbTab & objUser.TerminalServicesProfilePath)
End If
objRecordSet.MoveNext
Loop
objLogFile.WriteLine (i & " modifications finished at " & Now)
objErrorLog.WriteLine (e & " errors occured")
objLogFile.WriteLine ()
objErrorLog.WriteLine ()
objLogFile.Close
objErrorLog.Close
"anthonyy" wrote:
Hello, I work at a company that uses Active Directory, 2003 Servers and.
mostly Windows XP workstations. In AD we have a USERS container with all of
our users. We want to be able to change the Terminal Services User Profile
Path that is located on the Terminal Services Profile tab, in each users
properties. I designed a script to work for one specific user,
Const Enabled = 1
Const Disabled = 0
Set objUser = GetObject _
("LDAP://cn=tony1,cn=users,dc=asg,dc=com")
objUser.TerminalServicesProfilePath = "\\citrixserver4\rprofiles$\tony1"
objUser.SetInfo
Wscript.Echo "Done
I am looking for assistance in creating a script that will allow us to do
this for a larger group of users all in one shot. I have a test domain
environment to test this in, but any assistance would be greatly appreciated.
Thanks,
Tony
- Prev by Date: Re: Script help
- Next by Date: Vbscript control
- Previous by thread: Script help
- Next by thread: Vbscript control
- Index(es):
Relevant Pages
|
|