RE: Terminal Services Profile Path Script



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
.



Relevant Pages

  • Re: Setting environment variables in IIS 6.0 [PERL @INC MANIPULATION]
    ... included the sample drsaticly reduced VBS script below - the script will add ... > Only option I can think of is to write to the IIS Admin APIs using script. ... Const L_ChkCmdLibReg_ErrorMessage = "Please register the ...
    (microsoft.public.inetserver.iis)
  • Script not Functioning Properly
    ... the script is supposed to automatically reply to any new ... Const CdoPR_ACTION_FLAG = &H10810003 ... Public Sub Folder_OnMessageCreated ...
    (microsoft.public.outlook.program_vba)
  • Re: From Workgroup to Domain
    ... Ok thank you for the help - nice to see the script run:) ... it should help the win2k clients. ... Gibraltar skrev: ... Const JOIN_DOMAIN = 1 ...
    (microsoft.public.windows.server.active_directory)
  • [code] getting your script to talk to you
    ... SAPI comes as an actX object, and so is programmable using vbs. ... There was only one small script for sapi that I could find here, ... Dim oSpVoice, sText ... Const SVSF_Default = 0 ...
    (microsoft.public.scripting.vbscript)
  • Re: Change Computer Name
    ... I also found a script from that site to join the domain. ... Dim objWMIService, colComputers, objComputer ... Dim NewName, Result ... Const JOIN_DOMAIN = 1 ...
    (microsoft.public.windows.server.scripting)