As part of a bigger script I need to verify a file contents before continuing. However, it's not working when I use | Out-String.
Note this needs to work under powershell v2 unfortunately. The file I am looking at contains the data:
{"somedata":5,"hello":[]}
If I remove | Out-String from the command then it tells me the file matches.
But if I add data to the file, then it still tells me the file matches when it doesn't. If I add | Out-String then it tells me the file doesn't match when it does...
$filecheck = Get-Content ("C:\temp\hello.txt") | Out-String
Write-Host $filecheck
if ($filecheck -eq '{"somedata":5,"hello":[]}') {
Write-Host "file matches"
} else {
Write-Host "doesn't match"
}