I have done some programming on Unix/Linux, but lately PowerShell has been more useful in my work. However the lack of grep
drives me mad. Can someone explain this phenomenon?
I am trying to get the value of IOTA for today returned to a value that I can Write-Output
.
$webpage = Invoke-WebRequest -Uri https://coinmarketcap.com/currencies/iota/
$filtered = $webpage.ParsedHtml.body.innerText
This gives me all the information I need, but it needs more filtering.
$filtered | Select-String "IOTA"
This gives me all the information in $filtered
, somehow it does not manage to select that string. However, if I do this it works:
$filtered > filter.txt
Get-Content filter.txt | Select-String "IOTA"
I have been trying to search the web for answers, the closest thing I found is that it maybe processes $filtered
as an object, not a string. If I check, it says it is a string.
PS> $filtered.GetType() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True String System.Object
This is not my first experience of Select-String
failure. What am I doing wrong?