Last active
October 2, 2015 14:03
-
-
Save tjmichael81/ed5501bba798b2fe9341 to your computer and use it in GitHub Desktop.
AWS - Create instance image w/ Powershell
This file contains 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
# Task Scheduler run as powershell -f "<path to script>" | |
# General Script Variables | |
$serverName = "<server name>" | |
$date = Get-Date -UFormat "%m/%d/%Y" | |
$imageName = "$serverName $date" | |
# Retrieve instance ID from EC2 Instance Metadata | |
$instanceID = (New-Object System.Net.WebClient).DownloadString("http://169.254.169.254/latest/meta-data/instance-id") | |
# Create instance image. -NoReboot:$false stops the instance prior to creating the image | |
New-EC2Image -InstanceId $instanceID -Name $imageName -Description "Test Server Image" -NoReboot:$false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment