Exchange Powershell - Check if a user is in a specific mailbox database
14,808
Try with the Filter parameter (you can also use Name instead of Alias):
Get-Mailbox -Database "Archive Mailbox Database" -Filter {Alias -eq 'Fbloggs'}
Or the other way around:
(Get-Mailbox -Identity Fbloggs).Database.Name
Or
Get-Mailbox -Database "Archive Mailbox Database" | Where-Object {$_.Name -eq 'Fbloggs'}
Author by
noangel
Updated on June 04, 2022Comments
-
noangel almost 2 years
I am trying to writing a script to move a user to a new database and then export their mailbox to pst, but I need to verify if the user is in the correct database to begin with from a user input.
I am trying a command like:
Then I would error trap if the user is not found. This line does not work however with error:Get-Mailbox -Database "Archive Mailbox Database" -Identity Fbloggs
Parameter set cannot be resolved using the specified named parameters. + CategoryInfo : InvalidArgument: (:) [Get-Mailbox], ParameterBindingException + FullyQualifiedErrorId : AmbiguousParameterSet,Get-Mailbox
Many thanks for any help.
NA