0
New-Ec2Tag関数にいくつかの変数を渡す小さなラッパー関数があります。私がそれを実行すると、Amazon.Runtime.AWSCredentials にSystem.Object []に変換され、変換されてエラーが返されます。AWS Powershell関数は、AWSCredentialsをSystem.Objectに変換します。
この機能を動作させる方法はありますか?
機能
function addTag ($awscred, $instanceID, $TagName, $TagValue){
Write-output $awscred.gettype()
New-Ec2Tag -region 'ap-southeast-2' -Resource $instanceID -Tag @{Key=$TagName;Value=$TagValue} -Credential $AwsCredentials}
私は機能でそれをラップしていない場合、私は
write-output $AwsCredentials.gettype()
addTag($AwsCredentials,$instanceid,"Creator","123456")
コマンド出力
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False SessionAWSCredentials Amazon.Runtime.AWSCredentials
True True Object[] System.Array
New-EC2Tag : Cannot convert 'System.Object[]' to the type 'Amazon.Runtime.AWSCredentials' required by parameter 'Credential'. Specified method is not supported.
コマンドの動作を実行するコマンド
New-Ec2Tag -region 'ap-southeast-2' -Credential $AwsCredentials -Resource $instanceID -Tag (@{Key="Name";Value="test"})
ありがとう、私はそれを見落としたとは思わない – Shadowzee