Remote Connection to Exchange causing Active Roles performance issues
说明
When connecting remotely to Exchange within Active Roles script modules, it can cause the memory usage on the Active Roles service to increase until the process becomes unusable.
原因
The PSSessions are loading all the cmdlets and are not being properly closed off.
解决办法
There are two things to do when connecting remotely to Exchange in a PowerShell script module within ARS.
First is the make sure that you're always making use of the Disconnect-PSSession cmdlet. This on its own can make a significant difference if it's not currently implemented in your scripts.
Second is using the -CommandName parameter on the Import-PSSession cmdlet. This allows you to only import the cmdlets that you will require during your sessions. This drastically reduces the resources that are used during the PS sessions. Please see the following Microsoft article for more information on the Import-PSSession cmdlet: