无法在TFS Post构建脚本中执行AWS Powershell工具cmdlet



我试图执行几个aws cmdlet命令后构建脚本与TFS构建。我在构建控制器中安装了一个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 tfadfaadfaadfasdfadsfasdfasdxyz.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-tfsbc001wvc$MVBuildETA-API.ps1:41 char:26
 + cd "\b-tfsbc001wvC$" | 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-tfsbc001wvc$MVBuildETA-API.ps1:43 char:26
 + cd "\b-tfsbc001wvc$" | Write-S3Object -BucketName agero-source-package -File " ...
 +                          ~~~~~~~~~~~~~~
 + CategoryInfo          : ObjectNotFound: (Write-S3Object:String) [], CommandNotFoundException
 + FullyQualifiedErrorId : CommandNotFoundException

从错误消息来看,AWSPowerShell模块似乎无法被TFS构建进程运行的任何帐户找到/自动加载。

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

我在TFS构建代理上得到了相同的错误:

Set-DefaultAWSRegion:术语"Set-DefaultAWSRegion"不被识别为cmdlet、函数、脚本文件或可操作程序的名称。检查单词的拼写名称,或者如果包含路径,请验证路径是否正确,然后再试一次。

在我安装了AWS命令行接口 x64位(AWSCLI64)之后,我能够通过跳过代码行来设置Set-DefaultAWSRegion

我得到这个错误,直到我运行Powershell使用"运行作为管理员"。所以问题可能出在权限上

最新更新