Removing user profiles from terminal servers
Posted: 20 Jul 2015, 17:30
Hello,
I am trying to build something that will assist in managing user profiles within a large terminal server farm.
The intent is to use this for rebuilding user's profiles quickly, or for account terminations.
Goal:
Get the SID of a user from their domain name
Delete Registry key from HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\profilelist\%userSID%
Delete folder from c:\Users\%username%
Questions:
How do you get the SID of a different user?
Will FileDelete work with \\%servername%:HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\profilelist\%userSID%
Concept (certainly not working, but general idea of what I'm trying to put together):
Use Inputbox to simply enter user domain name into
save variable, query ASDI edit (or something else?) to get user SID.
Premade comma separated value of server list
loop server list looking for reg key and user folder and delete them
Thanks in advance for looking.
I am trying to build something that will assist in managing user profiles within a large terminal server farm.
The intent is to use this for rebuilding user's profiles quickly, or for account terminations.
Goal:
Get the SID of a user from their domain name
Delete Registry key from HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\profilelist\%userSID%
Delete folder from c:\Users\%username%
Questions:
How do you get the SID of a different user?
Will FileDelete work with \\%servername%:HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\profilelist\%userSID%
Concept (certainly not working, but general idea of what I'm trying to put together):
Use Inputbox to simply enter user domain name into
save variable, query ASDI edit (or something else?) to get user SID.
Premade comma separated value of server list
loop server list looking for reg key and user folder and delete them
Code: Select all
InputBox, username, Profile Remover, Enter the user's domain name.
servername = server1,server2,server3 ; many more servers, but you get the idea
; This part, I am unsure how to accomplish
; find SID and create %userSID% from %username%
loop, parse, servername , `,
{
filedelete, \\%servername%:HKEY_LOCAL_MACHINE, software\microsoft\windows nt\currentversion\profilelist\%userSID%
filedelete, \\%servername%\c$\Users\%username%
}