AWS Tools for Windows PowerShell

The AWS Tools for Windows PowerShell lets developers and administrators manage their AWS services from the Windows PowerShell scripting environment. Now you can manage your AWS resources with the same Windows PowerShell tools you use to manage your Windows environment.


Scenarios

  1. The AWS Tools for Windows PowerShell lets you perform many of the same actions available in the AWS SDK for .NET. You can use it from the command line for quick tasks, like controlling your Amazon EC2 instances.
  2. PS C:\> Start-EC2Instances -InstanceId i-10a64379
  3. The Windows PowerShell scripting language lets you compose scripts to automate your AWS service management. The following example loops through a log directory on an EC2 instance, finds files older than one week, and then archives any non-empty ones to Amazon S3 before deleting the old log file from disk.
  4. foreach ($i in Get-ChildItem C:\Logs)
    {
        if ($i.CreationTime -lt ($(Get-Date).AddDays(-7)))
        {
            if ($i.Length -gt 0)
            {
                Write-S3Object -BucketName mylogbucket -Key Logs/$i -File $i.FullName
            }
            Remove-Item $i.FullName
        }
    }
  5. Lastly, with direct access to AWS services from Windows PowerShell, your management scripts can now take advantage of everything the AWS cloud has to offer.
  6. # Catch an error and page all operators subscribed to the Amazon SNS topic
    Publish-SNSMessage -TopicArn arn:aws:sns:us-east-1:365928882516:OperationsError -Subject "Database Backup Failure" -Message "(details...)"
    
    # Publish a custom metric to your Amazon CloudWatch dashboard
    $dat = New-Object Amazon.CloudWatch.Model.MetricDatum
    $dat.Timestamp = (Get-Date).ToUniversalTime()
    $dat.MetricName = "New Posts"
    $dat.Unit = "Count"
    $dat.Value = $newPostCount
    Write-CWMetricData -Namespace "Usage Metrics" -MetricData $dat

Supported Services


Additional Resources