Skip to content

Instantly share code, notes, and snippets.

@JamesTryand
Created November 20, 2012 14:43
Show Gist options
  • Select an option

  • Save JamesTryand/4118342 to your computer and use it in GitHub Desktop.

Select an option

Save JamesTryand/4118342 to your computer and use it in GitHub Desktop.
Gets the email addresses from a Active Directory Group(s)
function Get-GroupMailAddresses {
PARAM([string[]]$GroupName)
BEGIN {
$DSGroupNameBasis = { PARAM([string]$Name) PROCESS { "(&(groupType=-2147483646)(name=$Name))" } }
}
PROCESS {
(new-object DirectoryServices.DirectorySearcher( & $DSGroupNameBasis -Name $GroupName )).
FindAll().
Properties['member'] |
% {
([ADSI]"LDAP://$_").mail
}
}
END { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment