3

我正在尝试使用 TFS 构建在构建后脚本中执行少数 aws cmdlet 命令。我在构建控制器中安装了 AWS SDK 工具。我可以在构建控制器中手动运行相同的命令。但是当我在 TFS 后构建脚本中调用这些命令时。它给我一个错误,它无法找到安装在构建控制器上的 cmdlet。我试图更改执行策略但没有帮助。我有一个执行策略 - 现在绕过。脚本正在执行,但只有命令无法执行。我认为这是因为执行政策之类的问题。当我们从 power shell 调用任何第三方 cmdlet 时,我们是否需要检查其他类似执行策略的内容。

命令:

Set-AWSCredentials -AccessKey  -SecretKey 

Set-DefaultAWSRegion -Region us-east-1

Write-S3Object -BucketName agero-source-package -File "\\b tfadfa\adfa\adf\asdf\adsf\asdf\asd\xyz.zip"

错误:

Set-DefaultAWSRegion : The term 'Set-DefaultAWSRegion' 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 \\b-tfsbc001wv\c$\MV\BuildETA-API.ps1:41 char:26
 + cd "\\b-tfsbc001wv\C$" | Set-DefaultAWSRegion -Region us-east-1
 +                          ~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo          : ObjectNotFound: (Set-DefaultAWSRegion:String) [], CommandNotFoundException
 + FullyQualifiedErrorId : CommandNotFoundException

 Write-S3Object : The term 'Write-S3Object' 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 \\b-tfsbc001wv\c$\MV\BuildETA-API.ps1:43 char:26
 + cd "\\b-tfsbc001wv\c$" | Write-S3Object -BucketName agero-source-package -File " ...
 +                          ~~~~~~~~~~~~~~
 + CategoryInfo          : ObjectNotFound: (Write-S3Object:String) [], CommandNotFoundException
 + FullyQualifiedErrorId : CommandNotFoundException
4

3 回答 3

1

我在 TFS 构建代理上遇到了同样的错误:

Set-DefaultAWSRegion :术语“Set-DefaultAWSRegion”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确并重试。

安装 AWS 命令​​行界面x64 位 (AWSCLI64) 后,我可以通过Set-DefaultAWSRegion跳过代码行来设置。

于 2019-02-04T22:01:23.857 回答
1

从错误消息来看,无论运行 TFS 构建过程的帐户如何,都无法找到/自动加载 AWSPowerShell 模块。

检查模块是否安装到全局可用的位置,您的 PowerShell 版本在该位置搜索模块,或者模块文件夹的路径是否存在于 TFS 构建帐户的 $PSModulePath 环境变量中。

于 2016-09-09T00:17:01.160 回答
0

在我使用“以管理员身份运行”运行 Powershell 之前,我收到了这个错误。所以问题可能出在权限上。

于 2018-03-07T15:53:03.277 回答