Announcement

Collapse
No announcement yet.

How to find empty OU

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to find empty OU

    Hi All,


    I am looking for command or script which will find EMPTY OU in AD.

    Looking for coomand..

    Thanks in advance.

    Regards
    Muneer

  • #2
    Re: How to find empty OU

    Code:
    @Echo Off
    SETLOCAL EnableDelayedExpansion
    
    IF EXIST C:\EmptyOUs.txt DEL /F /Q C:\EmptyOUs.txt
    SET OUQry=DSQuery OU -Name * -Limit 0
    FOR /F "delims=#" %%o IN ('%OUQry%') Do (
          Echo Processing: %%o
          DSQuery * %%o -Limit 0 | Find "CN=" >NUL
          IF ERRORLEVEL 1 Echo Empty OU: %%o >>C:\EmptyOUs.txt
    )
    Echo.
    Echo Search Complete! Check 'C:\EmptyOUs.txt' file.
    Echo.
    ENDLOCAL
    No credit to me, a coworker had sent that to me a while ago, and I Don't think it came from him originally .
    VCP on vSphere (4), MCITP:EA/DBA, MCTS:Blahblah

    Comment

    Working...
    X