Skip to content

Instantly share code, notes, and snippets.

@p0w3rsh3ll
Last active January 5, 2020 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p0w3rsh3ll/fffb01b6d7dd2861d4e81bc59b36fb68 to your computer and use it in GitHub Desktop.
Save p0w3rsh3ll/fffb01b6d7dd2861d4e81bc59b36fb68 to your computer and use it in GitHub Desktop.
Function Get-RemoteUserMailbox {
[CmdletBinding()]
Param(
[Parameter()]
[string]$SearchBase = "$((ActiveDirectory\Get-ADDomain).DistinguishedName)",
[Parameter()]
[int32]$ResultSetSize = 10000,
[Parameter()]
[string]$SearchScope = 'SubTree'
)
Begin {}
Process {
$HT = @{
Filter = 'msExchRecipientTypeDetails -eq 2147483648'
SearchScope = $SearchScope
ResultSetSize = $ResultSetSize
SearchBase = $SearchBase
ErrorAction = 'Stop'
}
try {
ActiveDirectory\Get-ADUser @HT
} catch {
Write-Warning -Message "Failed to query AD because $($_.Exception.Message)"
}
}
End {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment