bsharath
asked on
Find all disabled users direct reportees and remove them.
Hi,
I want a way to find all disabled users if they have direct reporters and remove them from the managers stste.
I have this that displays the users with direct reportees names.
DSQuery * -Filter "(&(objectCategory=user)(s amAccountN ame=*)(dir ectReports =*)(userAc countContr ol:1.2.840 .113556.1. 4.803:=2)) " >C:\DisabledUsersWithDirec tReports.
Can this be edited to remove them.,
Regards
Sharath
I want a way to find all disabled users if they have direct reporters and remove them from the managers stste.
I have this that displays the users with direct reportees names.
DSQuery * -Filter "(&(objectCategory=user)(s
Can this be edited to remove them.,
Regards
Sharath
Hi Sharath,
Check following script if this works for you.
:: *** SCRIPT START ***
@ECHO OFF
IF EXIST RemoveMgr.ldf DEL /F /Q RemoveMgr.ldf
DSQuery * -Filter "(&(sAMAccountType=8053063 68)(userAc countContr ol:1.2.840 .113556.1. 4.803:=2)( directRepo rts=*))" -Attr directReports -L -Limit 0 >RemoveMgr.txt
FOR /F "delims=*" %%u IN ('TYPE RemoveMgr.txt') DO (
ECHO Processing: %%u
( ECHO DN: %%u
ECHO changetype: modify
ECHO delete: Manager
ECHO -
ECHO.)>>RemoveMgr.ldf)
IF EXIST RemoveMgr.ldf LDIFDE -I -K -F RemoveMgr.ldf
IF EXIST RemoveMgr.ldf DEL /F /Q RemoveMgr.ldf
IF EXIST RemoveMgr.txt DEL /F /Q RemoveMgr.txt
EXIT /B 0
:: *** SCRIPT END ***
Check following script if this works for you.
:: *** SCRIPT START ***
@ECHO OFF
IF EXIST RemoveMgr.ldf DEL /F /Q RemoveMgr.ldf
DSQuery * -Filter "(&(sAMAccountType=8053063
FOR /F "delims=*" %%u IN ('TYPE RemoveMgr.txt') DO (
ECHO Processing: %%u
( ECHO DN: %%u
ECHO changetype: modify
ECHO delete: Manager
ECHO -
ECHO.)>>RemoveMgr.ldf)
IF EXIST RemoveMgr.ldf LDIFDE -I -K -F RemoveMgr.ldf
IF EXIST RemoveMgr.ldf DEL /F /Q RemoveMgr.ldf
IF EXIST RemoveMgr.txt DEL /F /Q RemoveMgr.txt
EXIT /B 0
:: *** SCRIPT END ***
ASKER
Farhan i think it works fine..But after it removes can i get a results file.On what has been removed...
ASKER
Its working fine.It has removed all users who have managers that are disabled...Thanks...If a report at the end is possible it would be great
What report should include?
ASKER
What all it has removed from direct reportees
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Farhan....
ASKER
Or instead of doing a Query, to a delete with the same fileter