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 AdminInfo.ca”.

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

 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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: