1

我使用 powershell 来盘点有关我们内部网站的信息。我跟踪的项目之一是该站点使用的数据库。以前,我使用过这样的 PowerShell 来获取连接字符串:

$allConnectionStrings = (Get-Webconfiguration $sitePath -filter "connectionStrings/add")

我现在有一个使用connectionStrings 标记上的configBuilders属性(https://docs.microsoft.com/en-us/aspnet/config-builder )的新站点,如下所示:

<connectionStrings configBuilders="SitecoreConnectionStringsBuilder">

并且 PowerShell 命令会引发此错误:


Get-Webconfiguration : Filename: \\?\C:\inetpub\wwwroot\MySite\web.config
Line number: 2
Error: Unrecognized attribute 'configBuilders'
At C:\scripts\Get-DatabaseNamesFromIisSite.ps1:89 char:34
+ ... nStrings = (get-webconfiguration $sitePath -filter "connectionStrings ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-WebConfiguration], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.GetConfigurationCommand

有没有办法让它适用于在 PowerShell 中使用 configBuilders 或使用 .NET 类的配置?该解决方案需要在站点代码之外工作——它必须在外部访问。

4

0 回答 0