DSCResources/DSC_KeyValuePairFile/en-US/about_KeyValuePairFile.help.txt

.NAME
    KeyValuePairFile
 
.DESCRIPTION
    The KeyValuePairFile resource is used to add, remove or set key/value pairs
    in a text file containing key/value pair entries.
 
    This resource is intended to be used to set key/value pair values in
    configuration or data files where no partitions or headings are used to
    separate entries and each line contains only a single entry.
 
    This resource should not be used to configure INI files.
    The IniSettingFile.md resource should be used instead.
 
.PARAMETER Path
    Key - String
    The path to the key value pair text file.
 
.PARAMETER Name
    Key - String
    The name of the key.
 
.PARAMETER Ensure
    Write - String
    Allowed values: Present, Absent
    Specifies the if the key value pair with the specified key should exist in the file.
 
.PARAMETER Type
    Write - String
    Allowed values: Text, Secret
    Specifies the value type to use as the replacement string. Defaults to 'Text'.
 
.PARAMETER Text
    Write - String
    The text to replace the value with in the identified key. Only used when Type is set to 'Text'.
 
.PARAMETER Secret
    Write - Instance
    The secret text to replace the value with in the identified key. Only used when Type is set to 'Secret'.
 
.PARAMETER IgnoreNameCase
    Write - Boolean
    Ignore the case of the name of the key. Defaults to $False.
 
.PARAMETER IgnoreValueCase
    Write - Boolean
    Ignore the case of any text or secret when determining if it they need to be updated. Defaults to $False.
 
.PARAMETER Encoding
    Write - String
    Allowed values: ASCII, BigEndianUnicode, BigEndianUTF32, UTF8, UTF32
    Specifies the file encoding. Defaults to ASCII
 
.EXAMPLE 1
 
Remove all `Core.Logging` keys in the file `c:\myapp\myapp.conf`.
 
Configuration KeyValuePairFile_RemovePlainTextPair_Config
{
    Import-DSCResource -ModuleName FileContentDsc
 
    Node localhost
    {
        KeyValuePairFile RemoveCoreLogging
        {
            Path = 'c:\myapp\myapp.conf'
            Name = 'Core.Logging'
            Ensure = 'Absent'
        }
    }
}
 
.EXAMPLE 2
 
Set all `Core.Logging` keys to `Information` or add it
if it is missing in the file `c:\myapp\myapp.conf`.
 
Configuration KeyValuePairFile_SetPlainTextPair_Config
{
    Import-DSCResource -ModuleName FileContentDsc
 
    Node localhost
    {
        KeyValuePairFile SetCoreLogging
        {
            Path = 'c:\myapp\myapp.conf'
            Name = 'Core.Logging'
            Ensure = 'Present'
            Text = 'Information'
        }
    }
}
 
.EXAMPLE 3
 
Set all `Core.Password` keys to the password provided in the $Secret
credential object or add it if it is missing in the file `c:\myapp\myapp.conf`.
 
Configuration KeyValuePairFile_SetSecretTextPair_Config
{
    param
    (
        [Parameter()]
        [ValidateNotNullorEmpty()]
        [PSCredential]
        $Secret
    )
 
    Import-DSCResource -ModuleName FileContentDsc
 
    Node localhost
    {
        KeyValuePairFile SetCorePassword
        {
            Path = 'c:\myapp\myapp.conf'
            Name = 'Core.Password'
            Ensure = 'Present'
            Type = 'Secret'
            Secret = $Secret
        }
    }
}