Posts Tagged control

SharePoint 2010: PowerShell script to add in web.config

Scenario:

We need to add an entry in “<assemblies>” section of the “web.config” file of specific web application using power shell script

Resolution:

Param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)]

[Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]

$WebApplication

)

$WebApp = $WebApplication.Read()

Write-Host $WebApp

$configMod = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification

$configMod.Name = “add[@name=""assembly""]“

$configMod.Path = “/configuration/system.web/compilation/assemblies”

$configMod.Value = “<add assembly=””AjaxControlToolkit, Version=3.0.30930.28736, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e”” />”

$configMod.Sequence = 0

$configMod.Type = 0 #for enum value of SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode

$configMod.Owner = “Ajax”

$WebApp.WebConfigModifications.Add($configMod)

$WebApp.Update()

$WebApp.Parent.ApplyWebConfigModifications()

Resource: http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/14/use-powershell-to-script-changes-to-the-sharepoint-web-config-file.aspx

Comments (1)

Follow

Get every new post delivered to your Inbox.