Summary: Speed up the connection to Exchange by importing only the cmdlets that you need.
Is there a way to speed up the initial PowerShell connection to Exchange?
Yes, of course! With a little modification to Import-PSSession, we can speed up the connection. Normally, you would connect to Exchange 2010/2013/2016 like this:
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 'http://ex01/PowerShell/?SerializationLevel=Full' -Authentication Kerberos
Import-PSSession -Session $session
This would import all available cmdlets in the local PowerShell session. But, consider the next example:
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 'http://ex01/PowerShell/?SerializationLevel=Full' -Authentication Kerberos
Import-PSSession -Session $session -CommandName Get-Mailbox,New-Mailbox,Enable-Mailbox,Set-Mailbox -FormatTypeName *
This would import only those cmdlets that you use, and this speeds up the import itself. This same kind of trick works also for the Active Directory module:
Import-Module -Name ActiveDirectory -Cmdlet Get-ADUser,New-ADUser,Set-ADUser
Post your questions on the Official Scripting Guys Forum. Also, check out my Microsoft Operations Management Suite Blog.
0 comments