how to stop $webapp.Parent.ApplyWebConfigModifications() updating all web applications in farm

561 Views Asked by At

$webapp.Parent.ApplyWebConfigModifications() updates all the webapplications in the farm.

For e.g. i have 2 web applications in my sharepoint farm.

webapp1 webapp2

I have web.config updates in webapp1 and below is the code using powershell

$webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($url)
$change = new-object "Microsoft.SharePoint.Administration.SPWebConfigModification"
$webapp.WebConfigModifications.Add($change)
$webapp.Update()
$webapp.Parent.ApplyWebConfigModifications()

this code works for webapp1 and webapp2 but when i run it for webapp2 i see an update in webapp1 config file also. Am i missing anything here ????

1

There are 1 best solutions below

1
JD Wade On

When you use SPWebConfigModication, the change is saved in the SharePoint configuration databases and populated out to all web.config files in the farm. Please see the following articles: http://msdn.microsoft.com/en-us/library/office/bb861909(v=office.14).aspx

http://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.administration.spwebservice.applywebconfigmodifications(v=office.14).aspx