/\/\o\/\/ on MSH (Monad): Report MP3 count and size by User from MSH
/\/\o\/\/ on MSH (Monad): Report MP3 count and size by User from MSHJust a great fun MSH script to play around with... As the topic says, it simply reports MP3 file statistics... on either local machine or on a network computer, etc...
But what is up with those @{expression=...;Name=...} stuff?
If you scroll down a bit, then you will run into two of "select" cmdlets with weird arguments.
Don't worry about it so much, argument is simply an array of a hashtable...
So let's see...
Let's take a look at,
# group them per user
"`n$Extension Per User"
$Userfiles | group Username | select @{expression={$_.Name};Name="User"},
@{expression={($_.group | measure-object).count};Name="Count"},
@{expression={($_.group | measure-object -property RoundedSize -sum).sum};Name="MB"}
you will just simply see an array of hashtable object with two keys with matching values
- 1st element
- expression: {$_.Name}
- Name: "User"
- 2nd element
- expression: {($_.group | measure-object).count}
- Name: "Count"
- 3rd element
- expression: {($_.group | measure-object -property RoundedSize -sum).sum}
- Name: "MB"
The value of "Name" key of each Hashobject is used as a header for the output while the values of "expression" evaluate piped input data object(in this case, System.Management.Automation.Commands.GroupInfo object) and spits out the output on the console.
In /\/\o\/\/'s case,
User Count MB
---- ----- --
Usr001 141 998,52
Usr002 547 3746,62
You can see that "User", "Count", and "MB" as headers and the results are simply calculated values from the piped input data.
BTW, to save typing, you don't have to go with something like
expression={$_.filename}; name="Filename"(probably for better readability?) since there is no real meaning to name your keys("expression" & "name") that long... For me being such a lazy typist... i was satisfied with the following...
$Userfiles | group Username | select @{e={$_.Name};N="User"},
@{e={($_.group | measure-object).count};N="Count"},
@{e={($_.group | measure-object -property RoundedSize -sum).sum};N="MB"}
Anyways, it was a fun fun script there /\/\o\/\/~~~
Tags :
Monad msh