Skip to content

Instantly share code, notes, and snippets.

@codecontemplator
Last active June 9, 2017 12:38
Show Gist options
  • Save codecontemplator/c72ececf633cf04e33ab454fea6bcf45 to your computer and use it in GitHub Desktop.
Save codecontemplator/c72ececf633cf04e33ab454fea6bcf45 to your computer and use it in GitHub Desktop.
Count mapping size per application
$doc = Get-Content .\mapping.txt -raw
$json = $doc.ToLower() | ConvertFrom-Json
function calc-num-properties($o)
{
$count = 0
if ($o)
{
$o | gm -membertype noteproperty | % {
$pn = $_.name
$count += 1 + (calc-num-properties ($o."$pn".properties))
}
}
return $count
}
$json.'serilog-2017.05'.mappings | gm -memberType noteproperty | select -expand name | % {
new-object psobject -property @{
name = $_
count = calc-num-properties $json.'serilog-2017.05'.mappings."$_".properties
}
} | sort -property count -descending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment