sql-server - SQL Server 作业无法识别 AWS CLI 命令

标签 sql-server powershell amazon-s3

您好,我有一个 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/

相关文章:

sql - 从 Excel 导入到 SQL Server : The 'Microsoft.ACE.OLEDB.12.0' provider error

c# - 向我解释这个 SELECT dbo.TableName(@variable) 语句

sql-server - 如何在 SQL Server 中的 NVARCHAR(MAX) 列上强制执行唯一性?

powershell - 在 Where-Object 条件之后获取第一个值

python - Django/报告实验室 : Save generated pdf directly to FileField in AWS s3

javascript - 将文件上传到 AWS S3 时获取未定义的文件名、文件类型

sql-server - 在SSIS中使用对象数据类型变量作为表名进行查询

powershell - 远程 PowerShell 到 AzureRM 虚拟机

c - 带有嵌套 for 循环的简单 C 程序在 Windows Powershell 中停止工作

amazon-web-services - 如何在 golang 中从 AWS S3 获取资源 URL