Last active
August 29, 2015 14:03
-
-
Save JogoShugh/b328854b440c3be5bea0 to your computer and use it in GitHub Desktop.
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
$b = [System.Text.Encoding]::UTF8.GetBytes((gc script.ps1)) | |
$script = [System.Convert]::ToBase64String($b) | |
$ami=Get-EC2Image -Owner self -Filters @{ Name="name"; Values="Clarity PPM Pristine Latest" } | select -expand ImageId | |
$resp = New-EC2Instance ` | |
-ImageId $ami ` | |
-MinCount 1 ` | |
-MaxCount 1 ` | |
-InstanceType c3.xlarge ` | |
-SecurityGroups windows_desktop_test ` | |
-EbsOptimized $true ` | |
-UserData $script | |
echo $resp | |
$resv = New-Object 'collections.generic.list[string]' | |
$resv.add($resp.ReservationId) | |
$resv_filter = New-Object Amazon.EC2.Model.Filter -Property @{Name = "reservation-id"; Values = $resv } | |
$instances = (Get-EC2Instance -Filter $resv_filter).Instances | |
$instance=$instances[0].InstanceId | |
echo "Setting a tag on $instance..." | |
$tag = New-Object Amazon.EC2.Model.Tag | |
$tag.Key = "Name" | |
$tag.Value = "Clarified Instance - Josh test" | |
$tagResp = New-EC2Tag -Resources $instance -Tags $tag |
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
Helpful info: | |
http://docs.aws.amazon.com/powershell/latest/userguide/pstools-ec2-launch.html | |
http://www.padisetty.com/2014/02/powershell-script-to-launch-and.html | |
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html |
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
<powershell> | |
mkdir "c:\aws\download" | |
Set-Location "c:\aws\download" | |
$wc = New-Object System.Net.WebClient | |
$myurl="http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip" | |
$wc.DownloadFile("$myurl","c:\aws\download\ec2.zip") | |
Set-Location "c:\aws\download" | |
$shell_app=new-object -com shell.application | |
$zip_file = $shell_app.namespace("c:\aws\download\ec2.zip"); | |
$destination = $shell_app.namespace((Get-Location).Path) | |
$destination.Copyhere($zip_file.items(),0x14) | |
</powershell> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment