Web Config Modifications using PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell
$oWebApp = Get-SPWebApplication http://SP2010
$oWebApp.WebConfigModifications
$oWebConfig = New-Object -TypeName Microsoft.SharePoint.Administration.SPWebConfigModification
$oWebConfig.name = "add[@key='TEST']"
$oWebConfig.path = "/configuration/appSettings"
$oWebConfig.value = "<add key='TEST' value='My Test' />"
$oWebConfig.owner = "oTest"
$oWebConfig.sequence = 0
$oWebConfig.type = [Microsoft.SharePoint.Administration.SPWebConfigModification+SPWebConfigModificationType]::EnsureChildNode
$oWebApp.WebConfigModifications.Add($oWebConfig)
$oWebApp.Update()
$oWebApp.Parent.ApplyWebConfigModifications()
GO to C:\inetpub\wwwroot\wss\VirtualDirectories\80
Open Web.config file, Search with "TEST", you will able to see <add key='TEST' value='My Test' />
Add-PSSnapin Microsoft.SharePoint.PowerShell
$oWebApp = Get-SPWebApplication http://SP2010
$oWebApp.WebConfigModifications
$oWebConfig = New-Object -TypeName Microsoft.SharePoint.Administration.SPWebConfigModification
$oWebConfig.name = "add[@key='TEST']"
$oWebConfig.path = "/configuration/appSettings"
$oWebConfig.value = "<add key='TEST' value='My Test' />"
$oWebConfig.owner = "oTest"
$oWebConfig.sequence = 0
$oWebConfig.type = [Microsoft.SharePoint.Administration.SPWebConfigModification+SPWebConfigModificationType]::EnsureChildNode
$oWebApp.WebConfigModifications.Add($oWebConfig)
$oWebApp.Update()
$oWebApp.Parent.ApplyWebConfigModifications()
GO to C:\inetpub\wwwroot\wss\VirtualDirectories\80
Open Web.config file, Search with "TEST", you will able to see <add key='TEST' value='My Test' />