This post applies to Exchange 2010.
By default, PowerShell has 7 Cmdlets loaded in the remote session for "import-session *" scenario which leads to about 30 MB of memory spike. Any additional Exchange help files that are loaded will cause additional spike. We will see this spike when users would call get-help on our Cmdlets, PowerShell is just preempting the spike.
In order to correct and prevent these spikes there is a manual configuration that can be done as part of the steps during an Exchange Server deployment. This configuration is not part of Exchange setup because the file belongs to PowerShell. In this particular case the change can be made using a simple script that will go into the PowerShell directory and make the necessary change to the ComandInfo object type removing the HelpUri property from it.
Running from ConfigurrePowerShell.cmd:
$path = "$pshome\types.ps1xml"
$xmlDoc = New-Object System.Xml.XmlDocument
$xmlDoc.Load($path)
$nodeList = $xmlDoc.GetElementsByTagName("Type")
$ShouldUpdateTypeFile = $false
foreach ($node in $nodeList)
{
if ($node.Name -eq "System.Management.Automation.CommandInfo")
{
foreach ($child in $node.Members.ChildNodes)
{
if ($child.Name -eq "HelpUri")
{
$removedChild = $node.Members.RemoveChild($child)
$ShouldUpdateTypeFile = $true
}
}
}
}
if($ShouldUpdateTypeFile)
{
$xmlDoc.Save($path)
}
This short script will iterate through the nodes of the types.ps1xml file removing the HelpUri property saving around 40Mb of memory by not loading all the help content for cmdlets in the beginning of the session. Note that this will have no bad effects, in other words you will still be able to use get-help.
You Had Me at EHLO.