en-us/Managing_Amazon_Web_Services_With_PowerShell_Pipeworks.walkthru.help.txt

# Powershell Pipeworks makes Amazon Web Services automatable.
# Instead of clicking thru the Amazon Web Services console, you can use PowerShell Pipeworks to perform actions automatically.
# For this part of pipeworks to work, you have to first install the C# sdk for AWS, and then use Set-AWSConnectionInfo to setup your account.
 
# Let's start out by listing all of the server core Amazon Machine Images:
Get-Ami -Keyword *Server*Core*
 
# Now, let's go ahead and add a new EC2 instance of Server Core:
$ServerName = "ServerCore$(Get-Random)"
Add-EC2 -Name $ServerName -ImageId ami-078b536e -PassThru
 
# Let's list all of the EC2 images with Get-EC2
Get-EC2
 
# This will take a while, but let's wait for the EC2 instance to become availabe
Get-EC2 -Name $ServerName |
    Wait-EC2
     
# Now that it's ready, we can actually get the instance password of the machine
Get-EC2 -Name $ServerName |
    Get-EC2InstancePassword
 
# We can connect to the server thru RDP.
Get-EC2 -Name $ServerName |
    Connect-EC2
     
# We can also open ports.
# Most AMIs already have PowerShell remoting on and enabled, but there's a command to open all of the ports for you.
Get-EC2 -Name $ServerName |
    Enable-EC2Remoting -PowerShellCredSSP -Ssh -Echo -Http -Https
     
# At this point, it's possible to Invoke-Command against the public DNS name, or, more conveniently, Invoke-EC2
Get-EC2 -Name $ServerName |
    Invoke-EC2 -ScriptBlock { "Good Morning, Euclid" }
     
# To save money, let's not keep the instance around any longer than it needs to be. This is the joy of the cloud.
Get-EC2 -Name $ServerName |
    Remove-EC2