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 Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,662 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,546 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andy David - MVP 149.1K Reputation points MVP
    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,386 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 Answers by the question author, which helps users to know the answer solved the author's problem.