Last active
June 9, 2017 12:38
-
-
Save codecontemplator/c72ececf633cf04e33ab454fea6bcf45 to your computer and use it in GitHub Desktop.
Count mapping size per application
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
$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