Hi,
I'm developing a template based mail library. As one example I've got the following "data gatherer":
$forest=Get-ADForest$domains=$forest.Domains$allUsers=foreach ($domainin$domains) {
Get-ADUser-Server $domain-Filter "mail -like '*'"-Properties givenName,surname,mail,userPrincipalName |Select-Object@{Name='Domain';Expression={$domain}},@{Name='FirstName';Expression={$_.givenName}},@{Name='LastName';Expression={$_.surname}},@{Name='Mail';Expression={$_.mail}},@{Name='UPN';Expression={$_.userPrincipalName}}
}
# Group by mail address and create array with required structure$userArray=$allUsers|Group-Object-Property Mail |ForEach-Object {
$firstUser=$_.Group|Select-Object-First 1
[PSCustomObject]@{
Mail=$_.NameFirstName=$firstUser.FirstNameLastName=$firstUser.LastNameUserList=$_.Group
}
}I'd like to use a template which creates a mail with a list of all users, but the loop is the problem (see it as pseudo code):
# Hello þFirstNameþ þLastNameþ,
Below you will find a list of your accounts grouped by domain:
## Accounts by Domain
þ{UserList | ForEach-Object {
"### Domain: $($_.Domain)"
"- UPN: $($_.UPN)"
} | Join-String -Separator "`n"}þ
Best regards,
Your IT Team
-Sascha aka callidus2000
Hi,
I'm developing a template based mail library. As one example I've got the following "data gatherer":
I'd like to use a template which creates a mail with a list of all users, but the loop is the problem (see it as pseudo code):
-Sascha aka callidus2000