PowerShell project, where to put global settings?


We are building a bigger project with PowerShell (a collection of scripts/functions that helps us setup some SharePoint environments/tenants).

A lot of the functions should reuse settings that are stored in a single, central place.

I couldn’t find a “best practice” of how such a settings file/location should be best created and structured.

My idea is to store global settings in a separate file (a module file), for example Settings.psm1 with content like this:

And in the other modules/scripts I then could always include those settings like this:

So this would make me able to use the global settings like this in the functions inside other script files:

Is this a good approach? Or shouldn’t I use module files for this and if not what kind of files should I use instead?


I would probably collect all your scripts/functions in a module and use the registry to store the global settings. Read the values from the registry when the module is loaded, and have variables with default values for each setting in your module so that you can write missing values to the registry.

Something like this:

For variables you only use inside your module you may want to use the script scope instead of the global scope.


PowerShell project, where to put global settings? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply