Skip to content

Instantly share code, notes, and snippets.

@JogoShugh
Last active August 29, 2015 14:03
Show Gist options
  • Save JogoShugh/b328854b440c3be5bea0 to your computer and use it in GitHub Desktop.
Save JogoShugh/b328854b440c3be5bea0 to your computer and use it in GitHub Desktop.
$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
<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