Skip to content

Instantly share code, notes, and snippets.

@mbrownnycnyc
Last active September 14, 2022 17:41
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 mbrownnycnyc/13506f5933ac2def56f82a9821606b40 to your computer and use it in GitHub Desktop.
Save mbrownnycnyc/13506f5933ac2def56f82a9821606b40 to your computer and use it in GitHub Desktop.
deal with json for filtering in powershell
# parse elbv2
$targetjson = get-content "elbv2-listener-allowing-cleartext.json" | ConvertFrom-Json
$interestingdata = @()
foreach ($item in $targetjson) {
$tempobj = "" | select dnsname, arn, vpcid, tags, listener_80_defaultaction_type, sg_tags, sg_used_by
$tempobj.dnsname = $item.DNSName
$tempobj.arn = $item.arn
$tempobj.vpcid = $item.VpcId
$tempobj.tags = $item.Tags
$tempobj.listener_80_defaultaction_type = (($item.listeners.80).DefaultActions).type
$tempobj.sg_tags = ($test.security_groups).used_by
}
#parse ssm app list
# get a list of all SSM managed instances
$ssmjson = aws ssm describe-instance-information
$ssmmanagedinstancedata = ($ssmjson | convertfrom-json).InstanceInformationList
$appdata = @()
$i = 0
foreach ($instanceid in $ssmmanagedinstancedata.instanceid) {
$i
$tempobj = "" | select instanceid, capturetime, applicationlist
$runonce = (aws ssm list-inventory-entries --instance-id "$instanceid" --type-name "AWS:Application") | convertfrom-json
$tempobj.instanceid = $runonce.instanceid
$tempobj.capturetime = $runonce.capturetime
$tempobj.applicationlist = $runonce.entries
$appdata += , $tempobj
$i++
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment