Here's how to do it.
$count = (get-content file1.txt | select-string -pattern "/export").length
As mentioned in the comments, this will return the number of lines containing the template, so if any line has more than one instance of the template, the count will be incorrect .
source
share