Skip to content

Instantly share code, notes, and snippets.

@tylergohl
Created September 10, 2018 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylergohl/8594fbfeaeb7c9d48b8b1a11a9a20100 to your computer and use it in GitHub Desktop.
Save tylergohl/8594fbfeaeb7c9d48b8b1a11a9a20100 to your computer and use it in GitHub Desktop.
# Find automation runs that have happened in the last 24 hours and the instances that they have run against
$Instances = (Get-SSMAutomationExecutionList | where-object { $_.DocumentName -like '*ssm-nightlyrecycle-doc*' -and $_.ExecutionStartTime -gt (Get-Date).AddHours(-24) } | Get-SSMAutomationExecution).Parameters
$InstanceIDs = ((Get-SSMAutomationExecutionList | where-object { $_.DocumentName -like '*ssm-nightlyrecycle-doc*' -and $_.ExecutionStartTime -gt (Get-Date).AddHours(-24) } | Get-SSMAutomationExecution).Parameters).Values
$Instances = ($InstanceIDs | Get-EC2Instance | Select-object -ExpandProperty Instances)
(($Instances.tag) | Where-Object Key -eq "Name").value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment