0
我想在Sharepoint web.config文件的appSetting中添加兩個鍵值。執行powershell腳本時出錯,在appSettings中添加兩個鍵
我發現下面的鏈接,我可以添加新鍵一個很好的例子使用下面的鏈接修改blobcache屬性,
和也。
http://farhanfaiz.wordpress.com/2011/09/07/sharepoint-2010-powershell-script-to-add-in-web-config/
這裏是我的代碼中添加Appsetting兩個鍵。
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 = "<add key= 'RedirectToPage' value='Main.aspx' />"
$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 = "<add key= 'isProd' value='false' />"
$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
}
}
但我的問題是,當我執行的代碼,我得到以下錯誤:
Exception calling "ApplyWebConfigModifications" with "0" argument(s): "'/' is a
n unexpected token.
任何投入將是非常有益的。