-
-
Save p0w3rsh3ll/fffb01b6d7dd2861d4e81bc59b36fb68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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