Welcome to Exchange Team Blog Sign in | Join | Help

Syndication

This Blog

HelpUri property from commandInfo object type

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.

- Mario Trigueros Solorio

Published Friday, October 23, 2009 2:10 PM by Exchange
Filed Under: , , ,

Comments

No Comments
New Comments to this post are disabled

News


This blog and its contents are provided "AS IS" with no warranties, and they confer no rights. Use of any included script samples are subject to the terms specified in the Terms of Use.
New! Would you like to suggest a topic for the Exchange team to blog about? Send suggestions to us.

Exchange Server 2010 - Get the Release Candidate



Poll:

Other Exchange Blogs from MSFT