Why you should not add you PowerShell modules to Windows directory

Mariusz Wojcik

In his presentations Getting Started with PowerShell 3.0 Jump Start & Advanced Tools & Scripting with PowerShell 3.0 Jump Start, Jason Helmick stresses that you should never put you PowerShell module in Windows directory (usually c:\windows\system32\WindowsPowerShell\…) but he doesn’t give a good explanation why you should not do that. I though that it may be useful for some people to understand why it is not such a good idea to do it.

First of all, You do not “own” that directory, Microsoft does. System updates, patches, hotfixes, they all may go and modify Windows directory, removing your files. Microsoft may decide to move that folder to some other place and it will not be a breaking change.

It’s usually not backed up. The obvious places to be backed up are user folders, especially user Documents. Windows folder is not. That means you can loose your modules when data needs to be restored from back.

It may be wiped out during OS upgrade. There is no guarantee that data in Windows folder will be preserved when upgrading Operating System. You may loose your modules.

It is a bad practice to go and mess up somebody’s else space. The Windows folder belongs to Microsoft, the Pester’s module folder belongs to Pester module and the RabbitMQTools module folder belongs to RabbitMQTools project. Unless you are contributing to any of those project you should not add anything there.

So, follow Jason’s advice and DO put your modules in PowerShell subfolder in user’s documents, not in Windows folder.