Get count from Powershell Group-Object -
i trying stats our code. works fine 1 module:
function counttestcases($path=$pwd) { get-childitem $path -recurse -include *.java | where-object {-not $_.psiscontainer } | select-string "extends componenttestcase", "extends databasedependenttestcase" | group-object pattern | select-object count }
but want run across modules csv output this:
module,#componenttestcase,#databasedependanttestcase module1,20,30 module2,12,1
unfortunately, if add
| select-obejct count
it doesn't work (although name does). not sure how around without writing code...
i couldnt simpler find way.. seems works
get-childitem $path -recurse -include *.cs | select-string "int", "string" | group-object pattern -ashashtable | foreach { new-object psobject -property @{ int = $_['int'].count; string = $_['string'].count; module = 'mymodulename'} } | select module, int, string
the output looks like
module int string ------ --- ------ mymodulename 19 78
i'm using string , int patterns, you'll have replace yours
Comments
Post a Comment