Login | |
|
 |
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" '================
|
|
| |
|
|
|
 |
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
|
|
| |
|
|
|
 |
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
|
|
| |
|
|
|
 |
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
|
|
| |
|
|
|
|
|