Forum Discussion
Slow performance when executing cmdlets through Powershell from a management server
We are trying to execute some management cmdlets to manage our distribution groups. We have a server having the Exchange Management Tools installed, not hosting any other Exchange Server roles. The command works well from an exchange server. When executing for example set-distributiongroup it takes some minutes to execute the command. It succeeds eventually . When running the command within a few minutes after the first try, it works fast. But when waiting for 5 or 6 minutes, it is slow again.
I ran the command with the verbose option, below you will find the output. The bold part is taking so long. This part is skipped when executing the command for the second time within some minutes:
Set-DistributionGroup <group-emailaddress> -AcceptMessagesOnlyFrom @{add=“<user-emailaddress>”} -verbose
VERBOSE: [13:03:12.395 GMT] Set-DistributionGroup : Runspace context: Executing user:
<executinguser>, Executing user organization: , Current
organization: , RBAC-enabled: Disabled.
VERBOSE: [13:03:12.399 GMT] Set-DistributionGroup : Active Directory session settings for
'Set-DistributionGroup' are: View Entire Forest: 'True',
VERBOSE: [13:03:12.399 GMT] Set-DistributionGroup : Beginning processing Set-DistributionGroup
VERBOSE: [13:03:12.406 GMT] Set-DistributionGroup : Instantiating handler with index 0 for cmdlet
extension agent "Rus Agent".
VERBOSE: [13:03:12.406 GMT] Set-DistributionGroup : Instantiating handler with index 1 for cmdlet
extension agent "Admin Audit Log Agent".
VERBOSE: [13:03:12.423 GMT] Set-DistributionGroup : Current ScopeSet is: { Recipient Read Scope:{{,
}}, Recipient Write Scopes:{{, }}, Configuration Read Scope:{{, }}, Configuration Write
Scope(s):{{, }, }, Exclusive Recipient Scope(s):{}, Exclusive Configuration Scope(s):{} }
VERBOSE: [13:03:12.431 GMT] Set-DistributionGroup : Searching objects
"<group-emailaddress>" of type "ADGroup" under the root "$null".
VERBOSE: [13:03:12.437 GMT] Set-DistributionGroup : Previous operation run on global catalog server
‘<GCserver>’.
VERBOSE: [13:03:12.437 GMT] Set-DistributionGroup : Rereading object
“<groupadobject>” of type "ADGroup" under the root
“<cngroupadobject>“.
VERBOSE: [13:03:12.437 GMT] Set-DistributionGroup : Previous operation run on domain controller
‘<DC>’.
VERBOSE: [13:03:12.437 GMT] Set-DistributionGroup : Searching objects
“<useremailaddress>“ of type "ADRecipient" under the root "$null".
VERBOSE: [13:03:12.453 GMT] Set-DistributionGroup : Previous operation run on global catalog server
'<GCserver>'.
VERBOSE: [13:03:12.453 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Update
Recipient object “<recipientadobject>“ with
ConfigurationDomainController "<null>", DomainController "<DC>”, GlobalCatalog
"<null>".
VERBOSE: [13:03:12.453 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Read Address
List for organization "" from domain controller <DC>.
VERBOSE: [13:03:12.462 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List "\".
VERBOSE: [13:03:12.462 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List "\".
VERBOSE: [13:03:12.462 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List "\Default Global Address List".
VERBOSE: [13:03:12.469 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List "\All Rooms".
VERBOSE: [13:03:12.469 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List “\xxxx”.
VERBOSE: [13:03:12.469 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List “\xxxx”.
VERBOSE: [13:03:12.469 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List "\All Contacts".
VERBOSE: [13:03:12.469 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List "\Public Folders".
VERBOSE: [13:03:12.469 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List "\All Distribution Lists".
VERBOSE: [13:03:12.469 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List "\External".
VERBOSE: [13:03:12.485 GMT] Set-DistributionGroup : [Microsoft Cmdlet Extension Agent] Found
Address List "\All Users".
VERBOSE: [13:03:12.485 GMT] Set-DistributionGroup : Processing object
"<groupadobject>".
VERBOSE: [13:03:12.485 GMT] Set-DistributionGroup : Admin Audit Log: Entered Handler:Validate.
VERBOSE: [13:03:12.493 GMT] Set-DistributionGroup : Admin Audit Log: Entered
ClassFactory:InitializeConfig.
VERBOSE: [13:07:03.950 GMT] Set-DistributionGroup : Admin Audit Log: Exited
ClassFactory:InitializeConfig.
VERBOSE: [13:07:03.966 GMT] Set-DistributionGroup : Admin Audit Log: Exited Handler:Validate.
VERBOSE: Setting distribution group "<group-emailaddress>".
VERBOSE: [13:07:03.966 GMT] Set-DistributionGroup : Resolved current organization: .
VERBOSE: [13:07:03.966 GMT] Set-DistributionGroup : PreInternalProcessRecord on cmdlet extension
agent index '0' returned object changed flag as 'False'.
VERBOSE: [13:07:03.966 GMT] Set-DistributionGroup : PreInternalProcessRecord on cmdlet extension
agent index '1' returned object changed flag as 'False'.
VERBOSE: [13:07:03.966 GMT] Set-DistributionGroup : No properties changed for the object
"<groupadobject>".
WARNING: The command completed successfully but no settings of
'<groupadobject>' have been modified.
VERBOSE: [13:07:03.966 GMT] Set-DistributionGroup : Saving object
"<groupadobject>" of type "ADGroup" and state "Unchanged".
VERBOSE: [13:07:03.982 GMT] Set-DistributionGroup : Previous operation run on domain controller
'<DC>'.
VERBOSE: [13:07:03.982 GMT] Set-DistributionGroup : Admin Audit Log: Entered Handler:OnComplete.
VERBOSE: [13:07:03.982 GMT] Set-DistributionGroup : Admin Audit Log: Exited Handler:OnComplete.
VERBOSE: [13:07:03.982 GMT] Set-DistributionGroup : Ending processing Set-DistributionGroup
Some got an idea what could be causing this delay?
Using the lastest Exchange 2019 versions with updates.
2 Replies
- RodPayneCopper Contributor
kevinmoonen, Microsoft has just updated the https://learn.microsoft.com/en-us/Exchange/manage-hybrid-exchange-recipients-with-management-tools#prepare-the-exchange-environment document to add a note:
"When you shut down your final Exchange server and test the create and update commands like New- or Set-RemoteMailbox, you'll observe significant increase in latency. This is because the Admin Audit Log initializer attempts to connect to the powered-down Exchange server, causing a timeout delay of approximately 40 seconds. After cleaning up the server in Active Directory using the CleanupActiveDirectoryEMT.ps1 script mentioned in the Active Directory clean up section, this delay is no longer present."
I haven't been able to test this out yet (because I'm stuck on Step 5b of Permanently Shutting Down Your Last Exchange Server), but at least they admit that there is a problem (that unfortunately they are not going to fix). - RodPayneCopper Contributor
We have the same problem that we noticed with Set-RemoteMailbox cmdlet under Exchange 2019 EMT in ClassFactory:InitializeConfig like yours. In our case, it works fine in our Development domain but takes 90 seconds in our Production domain.
Did you figure out anything on this?