exchange powershell issue

Jerry Su 201 Reputation points
2021-01-05T09:53:43.53+00:00

hello , I have a tricky issue with exchange management shell.

I have MBX1 ,MBX2, MBX3, MBX4 TOTAL 4 exchange 2016 servers.

MBX1 and MBX2 have a dag
MBX3 has all the shared mailbox so it doesn't with dag.
MBX4 has no mailbox on it, it only for the connect with exchange online (for hybrid deployment)

my laptop installed exchange management tools, and working fine (I often use my laptop to manage exchange with exchange management powershell)

today I discover I get no result when I runnging below command on my laptop.
But I get the expect result if I run the command on MBX 1 OR 2 OR 3 OR 4 (no matter which server)

Get-MailboxDatabase | Get-MailboxStatistics | Where{$_.DisconnectReason -eq "Disabled"}

anyone knows why ? thanks

Exchange | Exchange Server | Management
Exchange | Exchange Server | Management
The administration and maintenance of Microsoft Exchange Server to ensure secure, reliable, and efficient email and collaboration services across an organization.
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Answer accepted by question author
  1. Andy David - MVP 159.7K Reputation points MVP Volunteer Moderator
    2021-01-05T12:48:18.61+00:00

    This is a known issue with a few of the remote powershell commands. its looking for the -identity which is designates a mailbox rather then the database.
    ( It typically throws an error that the identity cant be found if you run your command from remote powershell)

    Running this same command on the Exchange Server directly as you have seen

    https://github.com/MicrosoftDocs/OfficeDocs-Exchange/issues/764

    The supposed way around this:

    $dbs = Get-MailboxDatabase
    $dbs | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} | where {$_.DisconnectReason -eq 'Disabled'} | Format-List 
    DisplayName,MailboxGuid,LegacyDN,Database
    

    However! Im not sure that really works either. I have run this in the past and it still doesnt produce results. I think its a bug in that command when run remotely to an Exchange Server.
    If you find it still doesnt work, then run only on an Exch Server directly.
    I dont think you are doing anything wrong necessarily, its just some bugginess. ( or by design haha)


5 additional answers

Sort by: Most helpful
  1. Eric Yin-MSFT 4,396 Reputation points
    2021-01-06T07:58:05.877+00:00

    I can't reproduce this issue because when I run "Get-MailboxDatabase | Get-MailboxStatistics | Where{$_.DisconnectReason -like "Disabled"}|ft displayname, disconnectreason", it failed with"The specified mailbox "Mailbox Database name" doesn't exist.”
    And if I changed "-eq" to "-like" in the script posted by Andy, it work for me:

     $dbs = Get-MailboxDatabase  
     $dbs | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} | where {$_.DisconnectReason -like 'Disabled'} | Format-List   
     DisplayName,MailboxGuid,LegacyDN,Database  
    

    The interesting thing is that I found another command in offical doc Get-MailboxStatistics that work in my lab, test with it please:

    Get-MailboxDatabase | Get-MailboxStatistics -Filter 'DisconnectDate -ne $null'  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.