Main | Contact | Blog | Documentation

PowerShell Framework

The project dedicated to empowering your PowerShell scripting.

Getting started with the Configuration system

The configuration system provides a central way to offer and discover settings. It can also be used to control & manage those settings from outside of scriptcode. It is designed to be used in both modules and individual scripts.

Implementing configuration

In order to set configuration up, you need to declare the configuration setting in a script that is run during import (in case of module) or at the top of the scriptfile (in case of a script).

Set-PSFConfig -FullName "MyModule.Mail.Server" -Value "mail.mydomain.com" -Validation string -Initialize -Description "Mail server used by the module to send alerts."

Later in the script / module we will want to use this setting. In the specific example, when sending an email obviously:

Send-MailMessage -SmtpServer (Get-PSFConfigValue -FullName 'MyModule.Mail.Server' -Fallback 'mail.mydomain.com') # ...

Additional Information

Further reading