小编Ozi*_*arb的帖子

传递字符串包含美元符号到-Replace Variable

我试图使用powershell替换.config文件中的句子.

${c:Web.config} = ${c:Web.config} -replace
Run Code Online (Sandbox Code Playgroud)

' $BASE_PATH$\Test\bin` $ Test_TYPE` $\WebTest.dll','c:\ program Files\example\webtest.dll'

每次我尝试运行上面的代码,我得到

"c:\ tests\runtesting.ps1 -replace <<<< $ BASE_PATH $\Test\bin\$ Test_TYPE $ .DLL

如果我不使用反引号,美元符号将消失,一些文字.

如何将字符串中的美元符号传递给替换?

powershell

6
推荐指数
1
解决办法
2万
查看次数

通过 Node.js 上的 Azure 函数获取当前经过身份验证的用户名

检索 O365/AzureAD 用户详细信息(例如在节点上使用 Azure 函数的用户名)的最佳方法是什么?

仅允许在线身份验证的用户使用Azure Function

我看到的所有示例都与 C# 上的 Azure Functions 相关。

azure-active-directory azure-functions

4
推荐指数
1
解决办法
2004
查看次数

Sql命令(使用"0"参数调用"ExecuteScalar"的异常)

当我第一次尝试运行下面的代码时,我得到一个无法解释的错误,但第二次尝试再次运行脚本工作正常......我的代码会出错?

顺便说一句,我在这一步之前创建数据库......

  $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
  $SqlConnection.ConnectionString = "Server=$dBServer;Database=$dBName;Integrated Security=True" 
  $SqlConnection.Open() 

  $SqlCmd = New-Object System.Data.SqlClient.SqlCommand 
  $SqlCmd.CommandText = $dBCmd 
  $SqlCmd.Connection = $sqlConnection 

  $execute = $SqlCmd.ExecuteScalar() 
  $SqlConnection.Close() 
Run Code Online (Sandbox Code Playgroud)

错误

Exception calling "ExecuteScalar" with "0" argument(s): "A transport-level error has occurred when sending the request to the server. (provider: Shared Memory  Provider, error: 0 - No process is on the other end of the pipe.)" At c:\scripts\DB\Powershell\RunSql.ps1:61 char:34
+   $execute = $sqlCmd.ExecuteScalar <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-2.0

2
推荐指数
1
解决办法
1万
查看次数