Remove-IniEntry

Removes an entry/line/setting from an INI file.

Syntax

Remove-IniEntry [-Path] <String> [-Name] <String> [[-Section] <String>] [-CaseSensitive] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

A configuration file consists of sections, led by a [section] header and followed by name = value entries. This function removes 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.

If the entry doesn't exist, does nothing.

Be default, operates on the INI file case-insensitively. If your INI is case-sensitive, use the -CaseSensitive switch.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Path String

The path to the INI file.

true false
Name String

The name of the INI entry to remove.

true false
Section String

The section of the INI where the entry should be set.

false false
CaseSensitive SwitchParameter

Removes INI entries 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.

EXAMPLE 1

Remove-IniEntry -Path C:\Projects\Carbon\StupidStupid.ini -Section rat -Name tails

Removes the tails item in the [rat] section of the C:\Projects\Carbon\StupidStupid.ini file.

EXAMPLE 2

Remove-IniEntry -Path C:\Users\me\npmrc -Name 'prefix' -CaseSensitive

Demonstrates how to remove an INI entry in an INI file that is case-sensitive.