术语 'EXEC' 未被识别为 cmdlet Powershell 的名称
The term 'EXEC' is not recognized as the name of a cmdlet Powershell
我有一个 SSIS dtsx 包,我想 运行 使用 PowerShell。下面是我在 powershell 中 运行ning 的内容。
EXEC xp_cmdshell '"C:\Program Files\Microsoft SQL Server0\DTS\Binn\DTExec.exe" /f "F:\SqlExport\New package.dtsx"'
不幸的是我收到以下错误,我不知道为什么
EXEC : The term 'EXEC' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ EXEC xp_cmdshell '"C:\Program Files\Microsoft SQL Server0\DTS\Binn ...
+ ~~~~
+ CategoryInfo : ObjectNotFound: (EXEC:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我也使用以下命令在 SQL 服务器中启用了 xp_cmdshell
EXEC xp_cmdshell
是 T-SQL statement 用于 通过 cmd.exe
.
启动 shell 命令
我推测其目的是让 PowerShell 执行以可执行路径 "C:\Program Files\Microsoft SQL Server0\DTS\Binn\DTExec.exe"
开头的命令,通过 EXEC xp_cmdshell
[从您的 T-SQL 脚本启动[= =46=][1]。
相反,您的错误消息暗示 PowerShell 执行了 整行,这可想而知地失败了:PowerShell 没有 EXEC
命令(并且您的系统上没有该名称的外部程序)。
也就是说,PowerShell 在这里既不需要,也不会进入画面,如果你的 EXEC xp_cmdshell
行已经被 SQL 服务器执行(通过 T-SQL 脚本)。
事实上,你的 T-SQL 命令应该可以正常工作 原样(调用带参数的外部程序,通过 cmd.exe
),如果 SQL 服务器正确执行。
[1] 更新:如果只是为了从 PowerShell
启动命令
& "C:\Program Files\Microsoft SQL Server0\DTS\Binn\DTExec.exe" /f "F:\SqlExport\New package.dtsx"`
请注意调用运算符 &
需要告诉 PowerShell 后面的双引号字符串是要调用的可执行文件的名称。
我有一个 SSIS dtsx 包,我想 运行 使用 PowerShell。下面是我在 powershell 中 运行ning 的内容。
EXEC xp_cmdshell '"C:\Program Files\Microsoft SQL Server0\DTS\Binn\DTExec.exe" /f "F:\SqlExport\New package.dtsx"'
不幸的是我收到以下错误,我不知道为什么
EXEC : The term 'EXEC' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + EXEC xp_cmdshell '"C:\Program Files\Microsoft SQL Server0\DTS\Binn ... + ~~~~ + CategoryInfo : ObjectNotFound: (EXEC:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
我也使用以下命令在 SQL 服务器中启用了 xp_cmdshell
EXEC xp_cmdshell
是 T-SQL statement 用于 通过 cmd.exe
.
我推测其目的是让 PowerShell 执行以可执行路径 "C:\Program Files\Microsoft SQL Server0\DTS\Binn\DTExec.exe"
开头的命令,通过 EXEC xp_cmdshell
[从您的 T-SQL 脚本启动[= =46=][1]。
相反,您的错误消息暗示 PowerShell 执行了 整行,这可想而知地失败了:PowerShell 没有 EXEC
命令(并且您的系统上没有该名称的外部程序)。
也就是说,PowerShell 在这里既不需要,也不会进入画面,如果你的 EXEC xp_cmdshell
行已经被 SQL 服务器执行(通过 T-SQL 脚本)。
事实上,你的 T-SQL 命令应该可以正常工作 原样(调用带参数的外部程序,通过 cmd.exe
),如果 SQL 服务器正确执行。
[1] 更新:如果只是为了从 PowerShell
启动命令& "C:\Program Files\Microsoft SQL Server0\DTS\Binn\DTExec.exe" /f "F:\SqlExport\New package.dtsx"`
请注意调用运算符 &
需要告诉 PowerShell 后面的双引号字符串是要调用的可执行文件的名称。