您好,我有一个 SQL Server 作业,其中包含一个 CmdExec
步骤,如下所示:
powershell.exe -file D:\Script\test.ps1
目前的 PowerShell 脚本很简单:
aws s3 ls s3://backup-sql-day/
奇怪的是,作业成功运行,并且出现了这条消息。
The term 'aws' 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 D:\Script\teste.ps1:1 char:1 + aws s3 ls s3://backup-sql-day/ + ~~~ + CategoryInfo : ObjectNotFound: (aws:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException.Process Exit Code 0. The step succeeded.
所以脚本不运行,不向我报告错误,问题是我似乎无法在 SQL Server 作业上运行任何 AWS 脚本,但是我可以与任何用户正常运行它,有人有吗知道如何解决这个问题吗?
最佳答案
(未损坏的)错误消息实际上是不言自明的。该脚本确实运行,但找不到 aws
命令行工具。 AWS CLI 安装路径未包含在 PATH
环境变量中,或者 SQL Server 作业忽略系统环境。
您可以通过在脚本中添加路径来解决该问题:
$env:Path += ';C:\Program Files\Amazon\AWSCLI'
aws s3 ls s3://backup-sql-day/
将 C:\Program Files\Amazon\AWSCLI
替换为安装该工具的文件夹。
关于sql-server - SQL Server 作业无法识别 AWS CLI 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34591708/