powershell - INI 文件中出现奇怪的 Powershell `Set-AWSCredentials` 错误

标签 powershell amazon-web-services amazon-s3 aws-powershell

我正在处理无人值守的 PowerShell 脚本,并希望以正确的方式存储 AWS 凭证。

根据 the documentation ,我应该能够将凭据存储在这样的 .ini 文件中

.\myAWSCredentials.ini

[default]
aws_access_key_id = XXXXXXXXXXXXXXX
aws_secret_access_key = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

[namedProfile]
aws_access_key_id = XXXXXXXXXXXXXXX
aws_secret_access_key = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

并将其加载到我的环境中
Set-AWSCredentials -ProfilesLocation .\myAWSCredentials.ini
或者
Set-AWSCredentials -ProfileName namedProfile -ProfilesLocation .\myAWSCredentials.ini
但是我收到一个没有意义的错误——PowerShell 与 App.config 文件有什么关系?

Set-AWSCredentials : Error loading stored credentials, (profile location = '.\myAWSCredentials.ini'). Error: App.config does not contain credentials information. Either add the AWSAccessKey and AWSSecretKey or AWSProfileName. At line:1 char:1 + Set-AWSCredentials -ProfilesLocation .\myAWSCredentials.ini + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Set-AWSCredentials], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Amazon.PowerShell.Common.SetCredentialsCmdlet

最佳答案

事实证明,在对此进行调查时,我们在处理最新版本(3.1.31.0 及更高版本)中的 .ini 格式文件时存在一个错误,我现在正在修复该错误。

如果您没有使用这些版本之一(并且我认为您不是基于这些版本中已修复的消息),请尝试将凭据文件的完整路径提供给 -ProfilesLocation - 可能是就 PowerShell 而言,“当前路径”并不是您在 cmdlet 运行时所认为的(我已经遇到了我尝试访问的其他文件,例如从我的个人资料中访问的文件)。

当我解决问题时,我会进一步更新。

关于powershell - INI 文件中出现奇怪的 Powershell `Set-AWSCredentials` 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34146066/

相关文章:

powershell - 'copy-item'不被识别为内部或外部命令

缺少某些功能的 Powershell Get-Verb 安装

powershell - 在 PowerShell 中重新加载路径

powershell - Powershell invoke-sqlcmd:值不能为null。参数名称:ServerInstance

amazon-web-services - AWS - 具有 TLS 终止但使用自签名证书到后端的负载均衡器?

amazon-s3 - AWS cloudformation 模板上的视频点播无法创建

amazon-web-services - AWS Pipeline部署cloudformation

amazon-web-services - 使用 aws cli 获取 S3 存储桶的 ARN

java - 如何将 Excel 文件从 AWS S3 存储桶获取到 Java 中的 MultipartFile 中

node.js - Elastic Transcoder AWS,如何增加缩略图大小?