Note that there are some explanatory texts on larger screens.

plurals
  1. POError while executing powershell script to add two keys in appSettings
    primarykey
    data
    text
    <p>I want to add two keys value in appSetting in Sharepoint web.config file. </p> <p>I found a good example modifying blobcache attribute using following link, </p> <p><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/14/use-powershell-to-script-changes-to-the-sharepoint-web-config-file.aspx" rel="nofollow">http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/14/use-powershell-to-script-changes-to-the-sharepoint-web-config-file.aspx</a></p> <p>and also following link where I can add new keys.</p> <p><a href="http://farhanfaiz.wordpress.com/2011/09/07/sharepoint-2010-powershell-script-to-add-in-web-config/" rel="nofollow">http://farhanfaiz.wordpress.com/2011/09/07/sharepoint-2010-powershell-script-to-add-in-web-config/</a></p> <p>And here is my code to add two keys in Appsetting.</p> <pre><code>function AddAppSettingKey { param( [Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)] [Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind] $WebApplication ) process { Write-Host "Modification starts..." -ForegroundColor Green $WebApp = $WebApplication.Read() Write-Host $WebApp $configMod1 = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification $configMod1.Path = "configuration/appSettings" $configMod1.Name = "add[@name='key']" $configMod1.Value = "&lt;add key= 'RedirectToPage' value='Main.aspx' /&gt;" $configMod1.Sequence = 0 $configMod1.Type = 1 $configMod1.Owner = "AppSettingMod" $configMod2 = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification $configMod2.Path = "configuration/appSettings" $configMod2.Name = "add[@name='key']" $configMod2.Value = "&lt;add key= 'isProd' value='false' /&gt;" $configMod2.Sequence = 0 $configMod2.Type = 1 $configMod2.Owner = "AppSettingMod" $WebApp.WebConfigModifications.Add($configMod1) $WebApp.WebConfigModifications.Add($configMod2) $WebApp.Update() $WebApp.Parent.ApplyWebConfigModifications() Write-Host "Done......" -ForegroundColor Cyan } } </code></pre> <p>But my problem is when I execute code, I get following error:</p> <pre><code>Exception calling "ApplyWebConfigModifications" with "0" argument(s): "'/' is a n unexpected token. </code></pre> <p>Any input will be very helpful.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload