I was required to produce the count of a particular string within a xmla file and output the count as a numeric to a variable.
First of all I introduced the content of my xmla file as a powershell variable unsing the Get-Content cmdlet
$Content = Get-Content “C:\My Folder\My File.xmla ”
Once I had the content of my text file as a variable I then used regular expression to match the search filter to the content variable and return the number of matches (.count).
$Count = [regex]::matches($Content,”My Search Filter”).count
Now by running the write-output cmdlet with the Content variable the numeric value is displayed