JSI Tip 8026. How can I 'net send' to all users in an Organizational Unit (OU)?

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
set query=dsquery user %1 -o samid
set message=%2
for /f %%u in ('%query%') do (
 net send "%%u" %message%
exit /b 0

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.