Updated PowerShell Scripts to Manage Symbol Server and Source Server Settings

1 Comment March 13, 2012


With Dev 11 Beta now in our hot little hands, I needed to update my symbol server and source server PowerShell scripts that automate setting up a developer machine. I’ve packaged up all the scripts previously published on this blog into a module, WintellectPowerShell, to make the cmdlets easier to use.

To set up a development machine to use a symbol server, use the Set-SymbolServer command. It takes care of setting the _NT_SYMBOL_PATH environment variable, as well as Visual Studio 2010 and Dev 11 Beta provided they are installed. The Set-SourceServer command sets up both VS 2010 and Dev 11, but also will set the _NT_SOURCE_PATH environment variable so WinDBG can pick up the source from your version control system as well. Yes, you C++ folks, these scripts support you as well!

I’ve also included an update version of my Get-SysinternalsSuite script that will download and extract all the wonderful Sysinternals tools. My previous version of the script relied on an external zip tool, but now used the Shell’s zip provider. There are a few other commands in the module for getting the current symbol server and source server values. The help is shown below and the download is here.

As always let me know if you find any bugs or have suggestions!

No discussion of PowerShell would be complete without a one-liner that does a lot. I wanted to show the help in this post so you could see all the commands. Once you have a module loaded, you can get the help simply by doing the following:

  1. (get-module WintellectPowerShell).ExportedFunctions.Keys | sort | foreach-object { Get-Help detailed $_}

I thought that was pretty cool!

  1. NAME
  2.     Expand-ZipFile
  3. SYNOPSIS
  4.     Expands a .ZIP file to the specified directory.
  5. SYNTAX
  6.     Expand-ZipFile [-ZipFile] <String> [-Destination] <String> [<CommonParameters>]
  7. DESCRIPTION
  8.     Using no external ZIP utilities, expands a .ZIP file to a specified directory.
  9. PARAMETERS
  10.     -ZipFile <String>
  11.         The .ZIP file to expand.
  12.     -Destination <String>
  13.         The output directory for the ZipFile. If this directory does not exist, it will
  14.         be created.
  15.  
  16. NAME
  17.     Get-SourceServer
  18. SYNOPSIS
  19.     Returns a hashtable of the current source server settings..
  20. SYNTAX
  21.     Get-SourceServer [<CommonParameters>]
  22. DESCRIPTION
  23.     Returns a hashtable with the current source server directories settings
  24.     for VS 2010, Dev 11 Beta, and the _NT_SOURCE_PATH enviroment variable used
  25.     by WinDBG.
  26.  
  27. NAME
  28.     Get-SourceServerFiles
  29. SYNOPSIS
  30.     Prepopulate your symbol cache with all your Source Server extracted source
  31.     code.
  32. SYNTAX
  33.     Get-SourceServerFiles [-CacheDirectory] <String> [[-SrcTool] <String>] [<CommonParameters>]
  34. DESCRIPTION
  35.     Recurses the specified symbol cache directory for PDB files with Source Server
  36.     sections and extracts the source code. This script is a simple wrapper around
  37.     SRCTOOl.EXE from the Debugging Tools for Windows (AKA WinDBG). If WinDBG is in
  38.     the PATH this script will find SRCTOOL.EXE. If WinDBG is not in your path, use
  39.     the SrcTool parameter to specify the complete path to the tool.
  40. PARAMETERS
  41.     -CacheDirectory <String>
  42.         The required cache directory for the local machine.
  43.     -SrcTool <String>
  44.         The optional parameter to specify where SRCTOOL.EXE resides.
  45.  
  46. NAME
  47.     Get-SymbolServer
  48. SYNOPSIS
  49.     Returns a hashtable of the current symbol server settings.
  50. SYNTAX
  51.     Get-SymbolServer [<CommonParameters>]
  52. DESCRIPTION
  53.     Returns a hashtable with the current source server directories settings
  54.     for VS 2010, Dev 11 Beta, and the _NT_SYMBOL_PATH enviroment variable.
  55.  
  56. NAME
  57.     Get-SysinternalsSuite
  58. SYNOPSIS
  59.     Gets all the wonderful Sysinternals tools
  60. SYNTAX
  61.     Get-SysinternalsSuite [-Extract] <String> [[-Save] <String>] [<CommonParameters>]
  62. DESCRIPTION
  63.     Downloads and extracts the Sysinternal tools to the directory you specify.
  64. PARAMETERS
  65.     -Extract <String>
  66.         The directory where you want to extract the Sysinternal tools.
  67.     -Save <String>
  68.         The default is to download the SysinternalsSuite.zip file and remove it after
  69.         extracting the contents. If you want to keep the file, specify the save
  70.         directory with this parameter.
  71.  
  72. NAME
  73.     Get-Uptime
  74. SYNOPSIS
  75.     Returns how long a computer has been running.
  76. SYNTAX
  77.     Get-Uptime [[-computerName] <String>] [<CommonParameters>]
  78. DESCRIPTION
  79.     Returns the TimeSpan for how long a computer is running. If you'd like it
  80.     formatted you can use "Get-Uptime -f {0}"
  81. PARAMETERS
  82.     -computerName <String>
  83.  
  84. NAME
  85.     Set-SourceServer
  86. SYNOPSIS
  87.     Sets the source server directory.
  88. SYNTAX
  89.     Set-SourceServer [-Directory] <String> [<CommonParameters>]
  90. DESCRIPTION
  91.     Sets the source server cache directory for VS 2010, Dev 11 Beta, and WinDBG
  92.     through the _NT_SOURCE_PATH environment variable to all reference the same
  93.     location. This ensures you only download the file once no matter which
  94.     debugger you use. Because this cmdlet sets an environment variable you
  95.     need to log off to ensure it's properly set.
  96. PARAMETERS
  97.     -Directory <String>
  98.         The directory to use. If the directory does not exist, it will be created.
  99.  
  100. NAME
  101.     Set-SymbolServer
  102. SYNOPSIS
  103.     Sets up a computer to use a symbol server.
  104. SYNTAX
  105.     Set-SymbolServer [-Internal] [-Public] [[-CacheDirectory] <String>] [[-SymbolServers] <String[]>] [-WhatIf] [-Confi
  106.     rm] [<CommonParameters>]
  107. DESCRIPTION
  108.     Sets up both the _NT_SYMBOL_PATH environment variable as well as Visual Studio
  109.     2010 and Dev 11 Beta (if installed) to use a common symbol cache directory as
  110.     well as common symbol servers.
  111. PARAMETERS
  112.     -Internal [<SwitchParameter>]
  113.         Sets the symbol server to use to http://SymWeb. Visual Studio will not use
  114.         the public symbol servers. This will turn off the .NET Framework Source
  115.         Stepping. This switch is intended for internal Microsoft use only.
  116.         You must specify either -Internal or -Public to the script.
  117.     -Public [<SwitchParameter>]
  118.         Sets the symbol server to use as the two public symbol servers from Microsoft.
  119.         All the appropriate settings are configured to properly have .NET Reference
  120.         Source stepping working.
  121.     -CacheDirectory <String>
  122.         Defaults to C:\SYMBOLS\PUBLIC\MicrosoftPublicSymbols for -Public and
  123.         C:\SYMBOLS\INTERNAL for -Internal.
  124.     -SymbolServers <String[]>
  125.         A string array of additional symbol servers to use. If -Internal is set, these
  126.         additional symbol servers will appear after HTTP://SYMWEB. If -Public is
  127.         set, these symbol servers will appear after the public symbol servers so both
  128.         the environment variable and Visual Studio have the same search order.

1 Comment

Have a Comment?

Archives

Blogs