Skip to content

Instantly share code, notes, and snippets.

View austoonz's full-sized avatar

Andrew Pearce austoonz

View GitHub Profile
@austoonz
austoonz / Lambda-SQS-Trigger
Last active January 15, 2019 03:38
A CloudFormation template sample to subscribe an AWS Lambda Function to an SQS Queue.
---
AWSTemplateFormatVersion: '2010-09-09'
Description: SQS Queue with Lambda Trigger
Parameters:
LambdaS3BucketName:
Type: String
Description: S3 Bucket Name holding the Lambda Function Package
(Get-Item -Path 'HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters').GetValue('HostName')
brew cask install quicklook-json
@austoonz
austoonz / Write-SSMInventoryExample
Created January 25, 2019 06:09
Sample code for writing an AWS Systems Manager Inventory record.
$powerShellModules = Get-Module -ListAvailable
$date = Get-Date -UFormat '+%Y-%m-%dT%H:%M:%SZ'
$inventoryItems = [System.Collections.Generic.List[Amazon.SimpleSystemsManagement.Model.InventoryItem]]::new()
$contentList = [System.Collections.Generic.List[System.Collections.Generic.Dictionary[System.String,System.String]]]::new()
foreach ($moduleName in ($powerShellModules | Select-Object -Property Name -Unique).Name)
{
$module = $powerShellModules.Where({$_.Name -eq $moduleName}) | Sort-Object -Property Version -Descending | Select-Object -First 1
$contentDictionary = [System.Collections.Generic.Dictionary[System.String,System.String]]::new()
@austoonz
austoonz / get-arm64-ami-ids
Created January 25, 2019 06:11
Sample code for retrieving the AWS AMI IDs for ARM64 images.
aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux-2/arm64/recommended
@austoonz
austoonz / Create-SSMAssociation
Created February 6, 2019 01:37
This scriptblock will create or update an AWS Systems Manager association
$ProfileName = ''
$AWSRegion = 'us-west-2'
$AssociationName = 'MyAssociationName'
$ComplianceSeverity = [Amazon.SimpleSystemsManagement.AssociationComplianceSeverity]::MEDIUM
$MaxConcurrency = '10%'
$MaxError = '5%'
$ExecutionTimeoutInSeconds = '300'
$ScheduleExpression = 'rate(1 hour)'
# Get a list of RSAT Capabilities
Get-WindowsCapability -Name RSAT* -Online | Select-Object -Property DisplayName, State
# Install RSAT
Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability -Online
@austoonz
austoonz / Invoke-FastPing
Last active March 1, 2019 17:02
A PowerShell Function that uses asynchronous ping commands to quickly ping a fleet of target machines.
# This has been replaced by the FastPing PowerShell Module.
## Source
[GitHub](]https://github.com/austoonz/FastPing)
## Installation
```powershell
Install-Module -Name FastPing -Scope CurrentUser
@austoonz
austoonz / Write-SSMComplianceItemExample
Last active April 5, 2019 22:31
Sample code for writing an AWS Systems Manager Compliance Item.
$managedInstanceId = (Get-Content -Path 'C:\ProgramData\Amazon\SSM\InstanceData\Vault\Store\RegistrationKey' -Raw | ConvertFrom-Json).instanceID
$moduleNames = @(
'AWSPowerShell',
'ClipboardText',
'Convert',
'PSWindowsUpdate'
)
$complianceItems = [System.Collections.Generic.List[Amazon.SimpleSystemsManagement.Model.ComplianceItemEntry]]::new()
foreach ($moduleName in $moduleNames)
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingCmdletAliases', '')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPlainTextForPassword', '')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]