Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a Windows 2008 R2 Domain with multiple outgoing trusts. In this domain we add the users from the trusted domains to domain local security groups. It seems that some or all deleted accounts from the foreign domains remain in the groups after deletion (from the originating domain), leaving a SID in the group which cannot be resolved.

What is the easiest way to find such accounts and remove them from the groups?

share|improve this question
up vote 0 down vote accepted

I dont have a script handy. But personally I'd do something like this.

  1. Enumerate objects in the cn=foreignsecurityprincipals,dc=doamin,dc=com container to build list of FPO SIDs
  2. Use a batch file to iterate through each and do a psgetsid.exe (sysinternals) against SID to see if it resolves. 0 means can resolve and -1 means unavailable or possibly even cant contact correct DC
  3. If %errorlevel% is -1 write that "bad" SID to another file

you can go through the SIDs reported as -1 to see if you really want to delete the FPO represented. Deleting the FPO will clean up any membership its used in. YOu can use DSRM to script deleting the FPO later if desired using a for loop to iterate txt file.

share|improve this answer
Yeah, I figured out a similar approach, but I hoped for an easier way. Thanks – Tom Oct 20 '11 at 7:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.