I have the following code:
get-content C:\file.txt | Foreach{($_ | Select-String "$" -all).Matches | measure | select count}
I want to find the number of $ in the file on each line, which works successfully, I am given a tabled count of the number of each character per line. However, I want to output each as a value to an array and perform an arithmetic operation on the count. As it stands everything I've tried has given me a multidimensional array in stead of an array of integers. For example I've tried
$counts = @(get-content C:\ampersand.txt | Foreach{($_ | Select-String "&" -all).Matches | measure | select count} )
but that just spits out a multidimensional array which I can't perform an arithmetic operation on
| select -expand count
help? Do you have an example of what you are trying to do with the output?