Here is a script that I have used many times.  It uses the new scripting objects for TS profiles that are available in Windows 2003.
 
-Stuart Fuller
 
========================================
Set Terminal Server Profile paths
'Uses W2K3 api - runs only from a Windows 2003 server
'by Stuart Fuller 10/1/03
 
Option Explicit
 
'Dimension variables
DIM strTSprof,strTShomepath,strTShomedrive,strOU
DIM objUser,adoConnection,ADsPath,adoRecordset
DIM userADsPath
DIM strTEST
 
'Set Constants
Const adStateOpen = 1
 
'==========Modify this part to what you want for TS profile, home, and home drive"
'Set TS path strings that you want
strTShomepath = "
\\someserver\home\"
strTShomedrive = "Z:"
strTSprof = "
\\someserver\profile\"
 
'==============Modify this part to the target user OU===========
'Set OU to modify
'example: "user,ou=finance,ou=corporate"
strOU = "users,ou=OU1"
 
'Establish adoConnection object
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADSDSOObject"
adoConnection.Open "", "", ""
 
'get users
'========Modify this bit to connect with your Active Directory========
'Example - dc=joewaredomain,dc=joeware,dc=net
Set adoRecordset = adoConnection.Execute _
("<
LDAP://ou=" & strOU & ",dc=childdomain,dc=parentdomain,dc=com>;(&(objectClass=User)(objectCategory=Person));" _
 & "Name,ADsPath,samAccountname;subtree")
 
'start loop and loop through users
 
While Not adoRecordset.EOF
 userADsPath = adoRecordset.Fields.Item("ADsPath").Value
 set objUser = GetObject(userADsPath)
 objUser.TerminalServicesHomeDirectory = strTShomepath & objUser.samAccountname
 objUser.TerminalServicesHomeDrive = strTShomedrive
 objUser.TerminalServicesProfilePath = strTSprof & objUser.samAccountname
 objUser.SetInfo
 adoRecordset.MoveNext
Wend
'end loop
 
'Clear vars and write finish message
adoConnection.Close
Set adoRecordset = Nothing
wscript.echo "Script Finish"
 


From: Jordan, Jason [EPM/AUS] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 27, 2004 1:46 PM
To: [EMAIL PROTECTED]
Subject: [ActiveDir] Modifying Terminal Services Settings En Masse

Well, I have a few questions that I think this group should be able to answer without breaking a sweat.
 
I need to write a script that can modify 2 particular settings for all users in a particular OU.  The settings I need to modify are the Terminal Services User Profile and Terminal Services Home Folder.  I am planning on using LDIFDE or CSVDE to make the modification.  I would like to set both of these settings for all users to \\SERVER\SHARE\DIRECTORY\%USERNAME%  Once these are set by the script, I will have to open each user and close them so that the Terminal Services Home Folder gets created on the share with the right permissions.
 
So here are my questions:
1.  What is the AD/LDAP name for the Terminal Services User Profile and Terminal Services Home Folder setting?
2.  Is there a better way than LDIFDE or CSVDE to make the modification?
3.  Is there a better way than opening and closing each user to get the home folder created and permissions updated?
 
Thanks in advance for all of your help.

jasonjordan MCSE, MCP+I, MCP
Sr. SQL DBA/Windows Network Administrator
Emerson Process Management, LLLP, Austin Data Center
(512) 832-3191

 

Reply via email to