$ds = new-object system.directoryservices.directorysearcher
function Find-Group($samName){
$ds.filter = ('(samaccountname={0})' -f $samName)
$ds.FindAll()
}
function Find-User($samName){
$ds.filter = ('(samaccountname={0})' -f $samName)
$ds.FindAll()
}
function Find-Members($groupName){
$group = Find-Group $groupName
$group.Properties.member | Get-Entry
}
function Get-Entry($cn){
begin{
if($cn){
new-object System.directoryservices.DirectoryEntry("LDAP://$cn")
}
}
process{
if($_){
new-object System.directoryservices.DirectoryEntry("LDAP://$_")
}
}
end{
}
}
(ok, three functions. Two are the same, I know)
No comments:
Post a Comment