2
votes

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:

Get-Mailbox -Database "Archive Mailbox Database" -Identity Fbloggs
Then I would error trap if the user is not found. This line does not work however with error:
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

1
Does the cmdlet work if you drop the -database argument? - Arcass

1 Answers

2
votes

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'}