Ash*_*sht 1 powershell sql-server-2008-r2
我正在尝试从 SQL Server 执行 Power Shell 脚本。每件事都对我有用,传递参数的静态值。但是当我尝试使用动态参数时,它不起作用。
以下是我正在尝试的声明:
declare @dteBatchDate as varchar(20)
set @dteBatchDate='2014-06-23 15:49:00'
EXEC xp_cmdshell 'powershell.exe -c "get-service | D:\Listing1.ps1 -@dteBatchDate"'
Run Code Online (Sandbox Code Playgroud)
我认为这是一个语法问题。任何机构都可以就此提出解决方案。
提前致谢
小智 5
您将变量传递给的方式xp_cmdshell不允许将其呈现给 PowerShell 以查看它。您基本上是从 PowerShell 提示符的角度执行此操作:
powershell.exe -c "get-service | D:\Listing1.ps1 -@dteBatchDate"
Run Code Online (Sandbox Code Playgroud)
以同样的方式,当您需要在 PowerShell 中执行命令之前呈现变量时,您必须对xp_cmdshell.
| 归档时间: |
|
| 查看次数: |
2610 次 |
| 最近记录: |