-
Notifications
You must be signed in to change notification settings - Fork 6
IniSettingsFile
dscbot edited this page Jul 5, 2020
·
4 revisions
| Parameter | Attribute | DataType | Description | Allowed Values |
|---|---|---|---|---|
| Path | Key | String | The path to the INI settings file to set the entry in. | |
| Section | Key | String | The section to add or set the entry in. | |
| Key | Key | String | The name of the key to add or set in the section. | |
| Type | Write | String | Specifies the value type that contains the value to set the entry to. Defaults to 'Text'. | Text, Secret |
| Text | Write | String | The text to set the entry value to. Only used when Type is set to 'Text'. | |
| Secret | Write | PSCredential | The secret text to set the entry value to. Only used when Type is set to 'Secret'. |
The resource is used to add, set or clear entries in Windows INI settings files.
Set the Level entry in the [Logging] section to Information
in the file c:\myapp\myapp.ini.
Configuration IniSettingsFile_SetPlainTextEntry_Config
{
Import-DSCResource -ModuleName FileContentDsc
Node localhost
{
IniSettingsFile SetLogging
{
Path = 'c:\myapp\myapp.ini'
Section = 'Logging'
Key = 'Level'
Text = 'Information'
}
}
}Set the ConnectionString entry in the [Database] section to the password
provided in the $Secret credential object in the file c:\myapp\myapp.ini.
Configuration IniSettingsFile_SetSecretTextEntry_Config
{
param
(
[Parameter()]
[ValidateNotNullorEmpty()]
[PSCredential]
$Secret
)
Import-DSCResource -ModuleName FileContentDsc
Node localhost
{
IniSettingsFile SetConnectionString
{
Path = 'c:\myapp\myapp.ini'
Section = 'Database'
Key = 'ConnectionString'
Type = 'Secret'
Secret = $Secret
}
}
}