Network Administrator Knowledgebase

Jun 27 2008   10:56PM GMT

Send a Message to All Users in an OU

Michael Khanin Michael Khanin Profile: Michael Khanin

By using the DSQUERY command and “Net Send” we can send a message to all users in a given OU.
It’s really simple, create a script, name it NetSendOU.bat and use the following syntax:

NetSendOU OU Message

Where OU is the organizational unit, like “OU=Users,DC=AdminInfo,DC=Ca”, and Message is the message text, like “Hello from”.

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

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: