Using the DSQUERY command, I have scripted NetSendOU.bat to net send a message to all users in a given OU.

The syntax for using NetSendOU.bat is:

NetSendOU OU Message

Where OU is the organizational unit, like "OU=West Coast,DC=JSIINC,DC=COM", and Message is the message text, like "Hello world".

NetSendOU.bat contains:

                              @echo off                              if \{%2\}==\{\} @echo Syntax: NetSendOU OU "Message"&exit /b 1                              setlocal                              set query=dsquery user %1 -o samid                              set message=%2                              for /f %%u in ('%query%') do (                               net send "%%u" %message%                              )                              endlocal                              exit /b 0