Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


TerminalServicesProfilePath

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,57188
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> TerminalServicesProfilePath
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 TerminalServicesProfilePath - 2/28/2008 12:08:59 AM   
  Blaktro

 

Posts: 3
Score: 0
Joined: 2/28/2008
Status: offline
Hey,

I'm all new to VB scripting. I do know a lot about CMD and also can read most of VB scripts.
Now I've downoaded a script that is able to change the profile path and the home folder path in Active Directory.

Now I want to add the functionality to change the TerminalServicesProfilePath. So, if value is A, then change to B.

I can't get this to work. I included the script. Can someone take a look at this one. Thnx.

Sacha

'==========================================================================
' Description:   Change User properties in AD
' Scriptname:   Change_AD_Path_0.1.VBS
' Author:        Sacha Latuheru Log In Consultants
' Date:           27-02-2008
' Version:       0.1
' Info:       ---
'==========================================================================

'================
strOutputfile = "Users_ProfilePaths.txt"
If Right(LCase(WScript.FullName), 11) = "wscript.exe" Then
     Set objShell = CreateObject("WScript.Shell")
     objShell.Run "cmd /k cscript """ & WScript.ScriptFullName & """", 1, False
     Set objShell = Nothing
     WScript.Quit
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
strDetails = """User Name"",""Full Name"",""AdsPath"",""Script Path"",""Old Home Directory"",""New Home Directory"",""Old Profile Path"",""New Profile Path"""
strOldPath = "\\rvdk00fs001\profiles2\"
strNewPath = "\\rvdk00fs002\profiles2\"
strOldHomeDirectory = "\\rvdk00fs001\Users2\"
strNewHomeDirectory = "\\rvdk00fs002\Users2\"
strFilter = "(&(objectCategory=person)(objectClass=user)(profilePath=" & Replace(strOldPath, "\", "\5c") & "*))"
'(profilePath=" & strOldPath & "*)
'strFilter = "(&(objectClass=computer)(cn=" & strComputer & "))"
' Comma delimited list of attribute values to retrieve.
'strAttributes = "sAMAccountName,cn"
strAttributes = "samAccountName,cn,adsPath,ScriptPath,homeDirectory,profilePath"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute

' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
   ' Retrieve values and display.
     strUserName = adoRecordset.Fields("samAccountName").Value
     strFullName = adoRecordset.Fields("cn").Value
     strOUPath = Replace(adoRecordset.Fields("adsPath").Value, "LDAP://CN=" & strFullName & ",", "")
     strScriptPath = adoRecordset.Fields("ScriptPath").Value
     strOldHomeDirectory = adoRecordset.Fields("homeDirectory").Value
     strProfilePath = adoRecordset.Fields("profilePath").Value
     strNewProfile = strNewPath & Mid(strProfilePath, InStrRev(strProfilePath, "\") + 1)
     WScript.Echo "Processing " & strFullName
     Set objUser = GetObject(adoRecordset.Fields("adsPath").Value)
     objUser.profilePath = strNewProfile
     objUser.homeDirectory = strNewHomeDirectory & Mid(strOldHomeDirectory, InStrRev(strOldHomeDirectory, "\") + 1)
     objUser.SetInfo
     Set objUser = Nothing
     strDetails = strDetails & VbCrLf &_
           """" & strUserName & """" &_
           ",""" & strFullName & """" &_
           ",""" & strOUPath & """" &_
           ",""" & strScriptPath & """" &_
           ",""" & strOldHomeDirectory & """" &_
           ",""" & strNewHomeDirectory & Mid(strOldHomeDirectory, InStrRev(strOldHomeDirectory, "\") + 1) & """" &_
           ",""" & strProfilePath & """" &_
           ",""" & strNewProfile & """"
   ' Move to the next record in the recordset.
   adoRecordset.MoveNext
Loop
' Clean up.
adoRecordset.Close
Set adoRecordset = Nothing
adoConnection.Close
Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True)
objOutputFile.Write strDetails
objOutputFile.Close
Set objOutputFile = Nothing
WScript.Echo "Done"
MsgBox "Done"
'================
 
 
Post #: 1
 
 RE: TerminalServicesProfilePath - 2/28/2008 1:34:09 AM   
  ebgreen


Posts: 4971
Score: 31
Joined: 7/12/2005
Status: online
"I can't get this to work."

What doesn't work? Do you get an error? Does it do something wrong? Does it do nothing at all? How about a good problem statement?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Blaktro)
 
 
Post #: 2
 
 RE: TerminalServicesProfilePath - 2/28/2008 2:02:13 AM   
  Blaktro

 

Posts: 3
Score: 0
Joined: 2/28/2008
Status: offline
As mentioned in my post. I'm all new to VB scripting. I've downloaded this VB script, did some editing in it to make it work for my environment.

What I'm asking for is some help to include some code in this script.
I want to add functionality to change the Terminal Services Profile Path. I really don't know how to do it.

(in reply to Blaktro)
 
 
Post #: 3
 
 RE: TerminalServicesProfilePath - 2/28/2008 2:07:19 AM   
  ebgreen


Posts: 4971
Score: 31
Joined: 7/12/2005
Status: online
"I can't get this to work."


Implies that you have tried to get it to work. Have you? If you have then please post the code that you have actually tried and answer the questions that I asked.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Blaktro)
 
 
Post #: 4
 
 RE: TerminalServicesProfilePath - 2/28/2008 2:17:02 AM   
  Blaktro

 

Posts: 3
Score: 0
Joined: 2/28/2008
Status: offline
I added the following code to my VB script. No error, but it doesn't makes the changes.

  if UserOBJ.TerminalServicesProfilePath = "\\rvdk00fs001\tsprofiles2\" Then
  UserOBJ.TerminalServicesProfilePath = "\\rvdk00fs002\tsprofiles2\"
  end if

But what is most preferred is to make this work in the VB script.

strOldTSPath = "\\rvdk00fs001\tsprofiles2\"
strNewTSPath = "\\rvdk00fs002\tsprofiles2\"

< Message edited by Blaktro -- 2/28/2008 2:18:29 AM >

(in reply to Blaktro)
 
 
Post #: 5
 
 RE: TerminalServicesProfilePath - 2/28/2008 2:24:18 AM   
  ebgreen


Posts: 4971
Score: 31
Joined: 7/12/2005
Status: online
Change this:

if UserOBJ.TerminalServicesProfilePath = "\\rvdk00fs001\tsprofiles2\" Then
UserOBJ.TerminalServicesProfilePath = "\\rvdk00fs002\tsprofiles2\"
end if

to this:

if UserOBJ.TerminalServicesProfilePath = "\\rvdk00fs001\tsprofiles2\" Then
UserOBJ.TerminalServicesProfilePath = \\rvdk00fs002\tsprofiles2\
UserOBJ.SetInfo
end if

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Blaktro)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> TerminalServicesProfilePath Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts