JSI Tip 9307. How can I NET SEND to members of a group, using the distinguished name?


In tip 0757, I scripted SNDGRP.bat to perform a NET SEND to members of a domain security group, using the group sAMAccountName (SAMID.)

This tip introduces SndDGrpDN.bat to perform a NET SEND to members of a domain group, given the group's distinguished name. The group can be a security group or a distribution group.

The syntax for using SndDGrpDN.bat is:

SndDGrpDN GroupDN MSG

Where:

GroupDN is the distinguished name of the group.

MSG     is the message you wish to send.
NOTE: SndDGrpDN.bat uses DNGrpMbrs.bat. This means that imbedded domain groups are recursively expanded to arrive at a complete set of domain members.

SndDGrpDN.bat contains:

@echo off
if \{%2\}==\{\} @echo Syntax: SndDGrpDN GroupDN Message&goto :EOF
setlocal ENABLEDELAYEDEXPANSION
set grp=%1
set msg=####%2####
set msg=%msg:####"=%
set msg=%msg:"####=%
set msg=%msg:####=%
for /f "Tokens=1* Delims=;" %%a in ('DNGrpMbrs %grp%') do (
 for /f "Tokens=*" %%m in ('net send %%b %msg% 2^>nul^|FIND "The message was successfully sent"') do (
   @echo %%m
 )
)
endlocal



Hide comments

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.
Publish