This is my code to count lines, I only have 69 lines which has a value on each line:
Get-AppPackage | Select-Object -Property name, publisherid | Measure-Object -Property name -line
Output:
Lines Words Characters Property
----- ----- ---------- --------
71 Name
But it's counting enters as well which I don't need them.
Help?
Building on the helpful comments:
This is my code to count lines
Your code doesn't count lines.
It counts the number of .Name
property values whose stringified representation results in non-empty strings, because you're combining Measure-Object
's -Line
switch with (non-string) object input and a -Property
argument.
(Get-AppPackage).Count
.Name
property contains neither the empty string nor $null
, use the following - but note that this should be true of all objects returned by Get-AppPackage
:(Get-AppPackage | Where-Object Name).Count