Sets an entry in an INI file.
Set-IniEntry [-Path] <String> [-Name] <String> [[-Value] <String>] [[-Section] <String>] [-CaseSensitive] [-WhatIf] [-Confirm] [<CommonParameters>]
A configuration file consists of sections, led by a [section] header and followed by name = value entries. This function creates or updates an entry in an INI file. Something like this:
[ui]
username = Regina Spektor <regina@reginaspektor.com>
[extensions]
share =
extdiff =
Names are not allowed to contains the equal sign, =. Values can contain any character. The INI file is parsed using Split-Ini. See its documentation for more examples.
Be default, operates on the INI file case-insensitively. If your INI is case-sensitive, use the -CaseSensitive switch.
| Name | Type | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|---|
| Path | String | The path to the INI file to set. |
true | false | |
| Name | String | The name of the INI entry being set. |
true | false | |
| Value | String | The value of the INI entry being set. |
false | false | |
| Section | String | The section of the INI where the entry should be set. |
false | false | |
| CaseSensitive | SwitchParameter | Treat the INI file in a case-sensitive manner. |
false | false | False |
| WhatIf | SwitchParameter | false | false | ||
| Confirm | SwitchParameter | false | false | ||
| CommonParameters | This cmdlet supports common parameters. For more information type Get-Help about_CommonParameters. |
Set-IniEntry -Path C:\Users\rspektor\mercurial.ini -Section extensions -Name share -Value ''
If the C:\Users\rspektor\mercurial.ini file is empty, adds the following to it:
[extensions]
share =
Set-IniEntry -Path C:\Users\rspektor\music.ini -Name genres -Value 'alternative,rock'
If the music.ini file is empty, adds the following to it:
genres = alternative,rock
Set-IniEntry -Path C:\Users\rspektor\music.ini -Name genres -Value 'alternative,rock,world'
If the music.ini file contains the following:
genres = r&b
After running this command, music.ini will look like this:
genres = alternative,rock,world
Set-IniEntry -Path C:\users\me\npmrc -Name prefix -Value 'C:\Users\me\npm_modules' -CaseSensitive
Demonstrates how to set an INI entry in a case-sensitive file.