Productivity Tools

Tools written by an IT business manager, a passionate developer.

PowerShell Master Configuration

The module allows to store configuration for the PowerShell in one single file.

To use it you need to have set up an environment variable MasterConfigurationPath to the directory where you would like to store a configuration.

Environment Variable

In the given directory you need to have a JSON configuration file.

Configuration file

Configuration should be in a simple JSON format with the configuration in the key-value pair.

{   "Login": "14561018",    "Password":"p@ssword",    "NugetApiKey":"oy2kzj5fdsafdsafdfwefdgrehrthwywtfesgfdwjmvjezikvbee6be3u5m" }

Set-MasterConfiguration

To make setup easy, the module exposes the cmdlet which allows creating a directory and a file for configuration. Invoking Set-MasterConfiguration will:

Usage

To use the module call Get-MasterConfiguration with key.

GetMasterConfiguration

If you would like to see all config values, use -All switch. The same effect you will achieve without any parameter. GetMasterConfiguration

Module is based on MasterConfiguration NuGet package. For .NET application it is also needed to set up additional Environment Variable ASPNETCORE_ENVIRONMENT but in PowerSher Master Configuration this parameter is not mandatory as module force to use MasterConfiguration.

Refresh the PowerShell session

If you would open the code, during Set-MasterConfiguration I set up two environment variables for Machine and for Process. This is a consequence of a way how PowerShell managing Environment Variables: – When the first instance of PowerShell instance is invoked, it creates list of Environment Variables and keeps them as Process. Restarting PowerShell doesn’t refresh the variables.

Close Bitnami banner
Bitnami