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](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 - String
    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.
 
 
    .EXAMPLE
    Set all `Core.Logging` keys to `Information` or add it
    if it is missing in the file `c:\myapp\myapp.conf`.
 
Configuration Example
{
    param
    (
        [Parameter()]
        [System.String[]]
        $NodeName = 'localhost'
    )
 
    Import-DSCResource -ModuleName FileContentDsc
 
    Node $NodeName
    {
        KeyValuePairFile SetCoreLogging
        {
            Path = 'c:\myapp\myapp.conf'
            Name = 'Core.Logging'
            Ensure = 'Present'
            Text = 'Information'
        }
    }
}
 
 
    .EXAMPLE
    Remove all `Core.Logging` keys in the file `c:\myapp\myapp.conf`.
 
Configuration Example
{
    param
    (
        [Parameter()]
        [System.String[]]
        $NodeName = 'localhost'
    )
 
    Import-DSCResource -ModuleName FileContentDsc
 
    Node $NodeName
    {
        KeyValuePairFile RemoveCoreLogging
        {
            Path = 'c:\myapp\myapp.conf'
            Name = 'Core.Logging'
            Ensure = 'Absent'
        }
    }
}
 
 
    .EXAMPLE
    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 Example
{
    param
    (
        [Parameter()]
        [System.String[]]
        $NodeName = 'localhost',
 
        [Parameter()]
        [ValidateNotNullorEmpty()]
        [PSCredential]
        $Secret
    )
 
    Import-DSCResource -ModuleName FileContentDsc
 
    Node $NodeName
    {
        KeyValuePairFile SetCorePassword
        {
            Path = 'c:\myapp\myapp.conf'
            Name = 'Core.Password'
            Ensure = 'Present'
            Type = 'Secret'
            Secret = $Secret
        }
    }
}