Using DSQUERY, an Active Directory command-line tool, I have scripted DomOU.bat to return the OUs that are configured in your domain.
NOTE: DomOU.bat does NOT return the Domain Controllers OU.
The syntax for using DomOU.bat is:
DomOU
The output is displayed on the console, but you can redirect it to a file, using:
DomOU>FileName
You can process the results in a batch, using a script similar to:
@echo off setlocal for /f "Tokens=*" %%o in ('DomOU') do ( call :Process %%o ) endlocal exit /b 0 :process :: Process the OU here @echo %1DomOU.bat contains:
@echo off for /f "Tokens=*" %%o in ('dsquery ou domainroot^|findstr /v /i /c:"OU=Domain Controllers,"') do ( @echo %%o )
0 comments
Hide comments