?
Solved

Script to remove/delete Citrix users TSP in their AD profile

Posted on 2012-08-27
8
Medium Priority
?
836 Views
Last Modified: 2012-12-12
Hello there,

I am in process of migrating Citrix Full Desktop users from old farm (XA 4.5 farm) to new XenApp 6.5 farm.

I need a script which removes/deletes Terminal Services Profile path in users AD profile.

Please advise.

Thanks and Regards
0
Comment
Question by:goprasad
5 Comments
 
LVL 9

Accepted Solution

by:
Vijaya Reddy Pinnapa Reddy earned 750 total points
ID: 38339274
This little script will set the TS profile to 'strRootDir\SAMName.
maybe its of some use, dont forget to define your server share as strRootDir and domain name in the commandtext.....

This little script will set the TS profile to 'strRootDir\SAMName. 
maybe its of some use, dont forget to define your server share as strRootDir and domain name in the commandtext..... 

---------------------------------------- 
Set WshShell = WScript.CreateObject("WScript.Shell") 
CurDir = WshShell.CurrentDirectory 
' Enter your server/share value here, don't forget the trailing strRootDir = "\\SERVER\ProfileSHARE$\" 
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=YOUR,dc=DOMAINNAME' 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 
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 

Open in new window

0
 

Author Comment

by:goprasad
ID: 38347923
I just the TSP path to be deleted from the TSP tab in users AD profile, for the usernames extracted in a text file.
0
 
LVL 5

Assisted Solution

by:Kernel_Recovery_Tools
Kernel_Recovery_Tools earned 750 total points
ID: 38382623
0
 
LVL 32

Expert Comment

by:nappy_d
ID: 38390386
Is stead of mixing the two profiles up, iwould suggest making a second.GPO that will apply only when users login to your Citrix servers.

You may also what to create a second location to store their Citrix TS profiles.

I will post later today my gpo settins for this.
0
 

Author Comment

by:goprasad
ID: 38390586
Currently users in old XA 4.5 farm has profile stored in \\xxxxxfps\Profiles$\%username% and TSP in users AD profile tab has this path
Users when connecting to new XA 6.5 farm, Citrix Profile Management has been configured to created profile in \\xxxxxfps\CTXProfiles$\%username%

My objective is when user A is migrated from old to new farm, I would like to have the his old TSP path removed/deleted from his AD profile.

My plans is to migrate 50 users at a time, and I can run script to extract usernames and I want those 50 user's TSP profile path in AD to be deleted/removed.

Please advise
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question