PowerAddict.net

powerAddict.NET

by Lou Goban
IT Application Professional at Syntax

Search for a users in DLs or DDLs in EXO with PowerShell

Search for a users in DLs:

Clear-Host

# Array of users
$users = @('[email protected]','[email protected]')

# Search for a user in DLs
foreach ($user in $users)
{
  Write-Host "`r`nSearching for: $user" -ForegroundColor Cyan
  Get-DistributionGroup -ResultSize Unlimited | `
  Where-Object {(Get-DistributionGroupMember $_.Name -ResultSize Unlimited | foreach {$_.PrimarySmtpAddress}) -contains "$user"}
}

Search for a users in DDLs:

Clear-Host

# Array of users
$users = @('[email protected]','[email protected]')

# Search for a user in DDLs
foreach ($user in $users)
{
  Write-Host "`r`nSearching for: $user" -ForegroundColor Cyan
  Get-DynamicDistributionGroup -ResultSize Unlimited | `
  Where-Object {(Get-Recipient -ResultSize Unlimited -RecipientPreviewFilter $_.RecipientFilter | foreach {$_.PrimarySmtpAddress}) -contains "$user"}
}

Leave the first comment