2016-09-06 12 views

答えて

3

まず、PowerShellの5.0以降にAWSのPowerShellモジュールをインストールします。

Install-Module -Name AWSPowerShell -Scope CurrentUser -Force 

さて、IAMコンソールに移動し、アクセスキーを生成し、PowerShellで資格情報を設定するには、次のコマンドを使用します。

$AccessKey = '<YourAccessKey>' 
$SecretKey = '<SecretKey>' 
$Region = 'us-west-1' 
Initialize-AWSDefaults -AccessKey $AccessKey -SecretKey $SecretKey -Region $Region 

今、あなたは、PowerShellのから認証されていることを、WPFウィンドウでEC2インスタンスのリストを開き、あなたがタグ付けしたいものを選択するには、以下のポップワンライナースクリプトを使用します。

(Get-EC2Instance).Instances | 
    Out-GridView -OutputMode Multiple | 
    ForEach-Object -Process { 
    New-EC2Tag -Tag (New-Object -TypeName Amazon.EC2.Model.Tag -ArgumentList @('Key', 'Value')) -Resource $PSItem.InstanceId 
    } 
2

PSコマンド

AWSのドキュメントから
New-EC2Tag -ResourceId $Instances -Tags $Tags 

....

$tag = New-Object Amazon.EC2.Model.Tag 
$tag.Key = "myTag" 
$tag.Value = "myTagValue" 

New-EC2Tag -Resource i-12345678 -Tag $tag 
関連する問題