Hi!
Description of what I'm trying to do: I filter some groups out of my Active Directory, All these groups contain "ABC-I", those groups got a value (persons) in the "Name" field of "ManagedBy" tab. All these persons should get an Email with the group members they are responsible for.
Thats what I've scripted.
#select the groups -works! $ABCGroups = Get-ADGroup -filter{name -like '*ABC-I-*'} -properties info, member, ManagedBy #filtering and editing the content I need -works not perfect, but for testing OK $Groups=ForEach ($ABCGroup in $ABCGroups){ If($ABCGroup.info -like '*cost*'){ [pscustomobject]@{ Name=$ABCGroup.Name Info=$ABCGroup.info Member=$ABCGroup.member ManagedBy=$ABCGroup.ManagedBy Costlocation=$ABCGroup.info.Split("[]")[2] Path=$ABCGroup.info.Split("[]")[6] } } } #here I filter the members of other groups the ABC person is responsible for - works .... .... #and send him/ her the email -works
So whats the problem? There are a lot of persons who are responsible for more than one group (some are responsible for hundreds), so this person will receive one email for each responsibility. I have to be sure that when I got Mr.X, the script filters all the stuff for Mr.X for all of his groups (placed with the other persons in $ABCGroup) and then sends the one email to him/ her.
I think somewhere I have to place a loop which checks if there are more members with the same name, workes the script for the same name and deletes this name because of the next loop round. Then go on with the other names. Maybe I have to work with a field? Or a better AD task?
Maybe someone can help! thanks a lot