Create WebConfigModification PowerShell

The WebConfigModification allow you to modif the web.config of the web application. It will be saved in the settings database.. When Apply the method ApplyWebConfigModifications of the the class SPWebService (Microsoft.SharePoint.Administration).

To create WebConfigModification


Add-PSSnapin "Microsoft.SharePoint.PowerShell"
#change the ur of your web application 
$webApp=Get-SPWebApplication -Identity "http://win-o2tqsp5voae:21288/"

 $bindig = New-Object "Microsoft.SharePoint.Administration.SPWebConfigModification"
 #The path to identifie the new node 
$bindig.Path = "configuration/system.serviceModel/bindings/basicHttpBinding"
#It is very important to deleting the node. By name SharePoint can find the
#node. must be unique to delete it. the format is: tagName[@name='Name'] 
$bindig.Name = "binding[@name='MyBinding']"
 $bindig.Sequence = 0
#the type of ConfigModification : 0= EnsureChildNode
 $bindig.Type = 0
#The owner of the modification
 $bindig.Owner = "MyWebConfigOwner"
 $bindig.Value = ""


To delete WebConfigModifcation

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

# Web appication URL
$webapp=Get-SPWebApplication -Identity "http://win-o2tqsp5voae:21288/"

#delete all WebConfigModification fo the Owner
$Modification = $webapp.WebConfigModifications | ? { $_.Owner -eq "MyWebConfigOwner"}
 if($Modification -ne $null){
 write-Host "Deleting existing entries"
 foreach($mod in $Modification){
Write-Host "Complete"
{Write-Host "no Item"}
This entry was posted in Administration, Power Shell and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s