PS C:\Projects>
get-childitem -recurse
| where { $_.Extension -eq ".csproj" }
| foreach { Get-Content $_.FullName
| foreach { $_.Length } }
This prints the line size of every line in a csproj (pretty pointless true). How can I also output a outer variable (so to speak) when I've dived further. So for example let's say for pointeless reasons I wanted to have it print the filename too so I would get:
Dog.csproj: 10 Dog.csproj: 50 Dog.csproj: 4 Cat.csproj: 100 Cat.csproj: 440
I figure I want to do something like this but this does not work obviously, (and yes the example is pointless)
PS C:\Projects>
get-childitem -recurse
| STORE THIS IN $filename | where { $_.Extension -eq ".csproj" }
| foreach { Get-Content $_.FullName
| foreach { $filename ":" $_.Length } }
I played with tee-object and outputvariable but I'm a bit lost. If a powershell guru could answer it would help, also if you could recommend a book or resource that explains the language syntax fundamentals rather than API monkey stuff of COM/WMI/VB etc.. (that seems most of what I came across) it would be most appreciated. Thanks