【问题标题】:Enable - SP Feature fails to find the configuration section in the web apps config启用 - SP 功能无法在 Web 应用程序配置中找到配置部分
【发布时间】:2011-09-28 01:02:37
【问题描述】:

我有一个网站,我想使用 powershell 为其激活功能

当我运行以下命令时:

enable-spfeature FEATURE NAME -url http://URL

它会抛出一个错误:value cannot be null parameter name section.

它基本上找不到位于 Web 应用程序配置下的配置部分。如果我创建一个名为 powershell.exe.config 的文件并将其放在 powershell 文件夹,它工作正常,但我不想触摸系统文件夹。

是否可以为 powershell 提供位于其他文件夹中的配置路径,并要求它在激活功能时使用该路径。

我尝试过这样的事情,但没有运气

$configpath = "C:\DevTools.exe.config"
 [System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE",$configpath)
enable-spfeature Feature name -url http://url

【问题讨论】:

    标签: c# sharepoint powershell


    【解决方案1】:

    为什么不把配置信息放在 web 应用程序 web.config 文件中?

    【讨论】:

      【解决方案2】:

      @Lee 从 powershell 激活功能需要配置在托管进程下,在这种情况下是 powershell。

      我的问题的解决方案是在运行时加载配置,如下所示,并使用 windows powershell 而不是使用 sharepoint 管理 shell:

      [System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE",$configpath)   
      add-type -path C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll
      Add-PSSnapin Microsoft.Sharepoint.PowerShell            
      enable-spfeature $FeatureName -url http:\\url
      

      【讨论】:

        猜你喜欢
        • 2012-05-05
        • 2015-02-19
        • 1970-01-01
        • 2011-12-30
        • 2015-05-05
        • 2015-12-30
        • 1970-01-01
        • 2020-04-01
        • 1970-01-01
        相关资源
        最近更新 更多