Deleting a user profile from multiple servers:
Ever needed to delete a users profile from 50+ servers? Ouch yes it happens, yes its annoying and yes it time consuming. I had a requirement to do this recently and i had to script it to save me logging into all 40+ Citrix servers and deleting the profile manually.
Now microsoft do have a tool called delprof and it is quite handy… but if you only want to delete one profile (not a whole rake of them) you are in trouble.
Step in the genius’s in ctrl alt del consultancy with remprof.exe. I’ve touched on this tool before, but today I’ve packaged a one stop batch file to delete a certain users profile from as many servers as you like!
The file relies on psexec, remprof and a text file containing the server names. if you are going to launch this from the network ensure you have the drive mapped. As with all my scripts it’s un-intrusive and wont leave you needing a restart.
The code can be found after the jump, if you dont care, you can find the script here:
@echo off
::Andrew Morgan 22/05/08
::Delete a users profile from a citrix server
::Relies on remprof.exe and servers.txt being in the installation folder
::servers.txt must have one servername per line and script must be as an administrative account.
@echo Kicking off script:
@echo.
::checking for servers list
ECHO Checking for servers list: & IF EXIST servers.txt (@echo Success & goto RemCheck) ELSE (@Echo Failure & goto txt-missing)
:RemCheck
::Checking for remprof.exe file
@echo.
ECHO Checking for Remprof.exe: & IF EXIST remprof.exe (@echo Success & goto psexeccheck) ELSE (@Echo Failure & goto rem-missing)
:psexeccheck
::Checking for psexec.exe file
@echo.
ECHO Checking for psexec.exe: & IF EXIST psexec.exe (@echo Success & goto set) ELSE (@Echo Failure & goto psexec-missing)
:set
::Setting username
@echo.
@echo please enter the nt login of the profile you wish to delete: & set /p user=
@echo.
@echo Deleting profile for %userdomain%\%user% from the specified servers.
goto install
exit
:install
psexec -accepteula @servers.txt -c remprof.exe %user%
@echo Command Completed, check above for results.
pause
exit
:rem-missing
@echo Error! Remprof.exe is missing from installation folder
@echo.
@echo. Check the script folder of this batch file for remprof.exe, if its not there, put it there, if it is there… panic.
pause
exit
:txt-missing
@echo servers.txt missing from installation folder
@echo.
@echo. Check the script folder of this batch file for servers.txt, if its not there, put it there, if it is there… panic.
pause
exit
:psexec-missing
@echo psexec.exe missing from installation folder
@echo.
@echo. Check the script folder of this batch file for psexec.exe, if its not there, put it there, if it is there… panic.
pause
exit
Excellent! Thank you for putting out this script. Saved lot of time!!!
Doesnt work, I get:
PsExec could not start remprof.exe on Server01:
The parameter is incorrect.
Any ideas?
Hi Gibbon,
It’s been a long time since i used this script, so i downloaded it again.
It seems to work ok for me, the parameter incorrect error would suggest to me that the username has a space in it (if this is the case wrap the name in quotes e.g. “user name”)
Failing that feel free to email me a screenshot of the error to andrew.morgan@o2.ie and i’ll take a look.
Just a quick update a new version of REMPROF is available for Windows 7, vista, and Windows 2008 environments. Download it at http://www.ctrl-alt-del.com.au/CAD_TSUtils.htm. Thanks for the support Andrew. Your script is brilliant!!
Hi Andrew. Is there any way I can get this working on multiple 2008R2 RDS servers where profiles are on D:\Users\ instead of C:\Users. Thanks – any help appreciated!
There sure is! Drop me an email on andrew@andrewmorgan.ie and we’ll talk about it.