Never Modify PowerShell's XML Files

Never Modify PowerShell's XML Files

  • Comments 7

Today we had a meeting about the installation of the next version of PowerShell on machines that had PowerShell V1.0 installed on them.  For reasons too painful and ugly to discuss, we are just going to replace any of the XML files (type extension and formatting files in $PSHOME) that WE INSTALLED in V1.0 (YOUR XML files are fine).  We are NOT going to make backups, detect modifications, nothing - we are going to pave and roll.

One of the hallmarks of a great PM is customer empathy proven by the fact that we had some PMS that were greatly concerned about customers that had taken our XML files and added their own customizations.  Let me share what is at the beginning of each of those files:

These sample files contain formatting information used by the Windows
PowerShell engine.
Do not edit or change the contents of this file
directly.
Please see the Windows PowerShell documentation or type
Get-Help Update-FormatData for more information.

We really mean it, we are going to replace those files without a second thought so if you've put customizations into those files - get them out into their own files.

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Leave a Comment
  • Please add 5 and 8 and type the answer here:
  • Post
  • PingBack from http://msdnrss.thecoderblogs.com/2008/03/21/

  • I think it's safer to pluralize as PMs.

  • I have a situation were I have two machines that will not allow me to uninstall version 1.0 to upgrade to ver. 2.

    What is the recommended course of action in this instance? Should I manually scrub version 1?

  • I think this is the correct decision to ensure stabile/predictable PowerShell installs, but it makes me wonder why you use XML in the first place.  XML is inefficient and full of fluff, but the biggest advantage is the standards-based human-readable format, so using XML is almost encouraging people to make changes.  It's quite common for software vendors would intentionally save things in a proprietry format so people would not be tempted to make changes, and if they did you could say well you shouldn't be hacking our files.  So I'm OK with the outcome of the meeting (pave and roll - LOL), I've made some custom formatting in my own files. But if this wasn't XML (or it was compressed/encoded) and you provided some XML formatting examples, you probably wouldn't have needed to have a painful and ugly meeting in the first place.

  • The included XML files are signed using an MS signature; modifying them breaks that signature. If you're running a secure ExecutionPolicy (AllSigned), a broken signature prevents the files from loading unless you re-sign it. So it makes a LOT more sense to just make your own files (www.sapienpress.com/powershell2.asp includes chapters on doing so) and load them in your profile - better security along with the described convenience when installing updates.

  • I just checked the XML files in C:\Windows\System32\WindowsPowerShell\v1.0\ and I don't see any signatures.

  • You might consider at least backing up the files if they differ from what's expected.  Any Linux package management system would do this. No reason to to be so hard about it.

Page 1 of 1 (7 items)