Created
January 11, 2022 03:11
-
-
Save Rugby-Ball/b186b4cecfd743307ed9ff005a09ab70 to your computer and use it in GitHub Desktop.
Set Tag and Value to all running Windows EC2 #EC2 #AWS #Public #Maintenance #Windows #Utility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #set-ec2-tag-all-running-windows-instances.ps1 | |
| <# | |
| Description: Set Tag and Value to all running Windows EC2 | |
| Written: Ed Walsh | |
| PowerShell.Core tested: Yes | |
| Version: 1.0.0 | |
| Create Date: 1/10/2022 | |
| Revised Date: 1/10/2022 | |
| #> | |
| $instances = ((Get-EC2Instance -Region $Region).Instances | Where-Object {$_.Platform -eq "Windows" -and $_.state.name -eq 'running'} ).InstanceId | |
| foreach ($i in $instances) | |
| { | |
| $tag = New-Object Amazon.EC2.Model.Tag | |
| $tag.Key = "managed" | |
| $tag.Value = "yes" | |
| New-EC2Tag -Resource $i -Tag $tag | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment