gpt4 book ai didi

amazon-web-services - 新对象 : Cannot find type [Amazon. EC2.Model.Tag]

转载 作者:行者123 更新时间:2023-12-05 02:52:57 26 4
gpt4 key购买 nike

我正在使用 New-EC2Tag 通过 Azure Pipeline 创建/更新 EC2 标签。我正在使用“适用于 Windows PowerShell 脚本的 AWS 工具”任务,下面是代码:

$Tag = New-Object Amazon.EC2.Model.Tag  
$Tag.Key = "DesiredInstanceState"
$Tag.Value = "Stopped"

New-EC2Tag -Resource $instanceName -Tag $Tag

任务运行时出现以下错误:

2020-06-16T18:40:57.4642775Z ##[error]New-Object : Cannot find type [Amazon.EC2.Model.Tag]: verify that the assembly containing this type is loaded. At C:\1_work_temp\d2378116-3224-4a4a-b92c-61744a291aac.ps1:2 char:8 + $Tag = New-Object Amazon.EC2.Model.Tag + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand 2020-06-16T18:40:57.4655375Z ##[error]PowerShell exited with code '1'.

我在构建服务器和我试图为其创建标签的服务器上都安装了该模块,仍然是一样的。

任何输入将不胜感激。谢谢!

最佳答案

正如@Mathias 在评论中所建议的那样,我更新了脚本以包含 Import-Module -name AWSPowerShell,它的效果非常好。

关于amazon-web-services - 新对象 : Cannot find type [Amazon. EC2.Model.Tag],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62416135/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com