Removing an invalid WebConfigModification using Powershell

SharePoint supports adding web.config modifications programmatically. Here is an example from MSDN. Each modification is stored with a web application, and you are able to list them using the following command:

$webapp = Get-SPWebApplication http://<your web app url>

If you want to remove an invalid entry, use the following commands:

$modification = $webapp.WebConfigModifications | where { $_.Name -eq "<the name of your key>" }