Reputation: 3280
I would like to check $true or $false if a user is in a specific mailboxdatabase. This doesn't work:
if((get-mailbox user| select Database) -eq "server\group\dbgroup") {
echo $true
} else {
echo $false
}
(returns False)
But
get-mailbox user | select Database
returns
Database
--------
server\group\dbgroup
How do I check for this value?
Upvotes: 0
Views: 2089
Reputation: 126902
@Christian already gave you the answer, but to answer you "syntax error". When you pipe to Select-Object you get back an object with the properties you specified: Database. To access the property you need to call it, so in order for your code to work you'd have to write it this way:
if((get-mailbox user| select Database).Database -eq "server\group\dbgroup") {
echo $true
} else {
echo $false
}
Upvotes: 1
Reputation: 60956
Try like this (can't test it):
if( (get-mailbox user).Database -eq "server\group\dbgroup")
Upvotes: 0