Last active
September 14, 2022 17:41
-
-
Save mbrownnycnyc/13506f5933ac2def56f82a9821606b40 to your computer and use it in GitHub Desktop.
deal with json for filtering in powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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