Basically I'm writing an updater for my script. It's supposed to compare itself (Get-Content -Path $PSCommandPath
) to the one on the web server (Invoke-WebRequest...
). However, it always shows an updated is available.
My understanding (from other questions here) is that -raw
will force it to return the file as a string which should be the same way the web request is returned. But I'm guessing the issue is somewhere in there. Hopefully a simple thing...
function checkUpdates() {
Write-Host "Checking for updates... " -NoNewline -ForegroundColor $clrMain
$item1 = Get-Content -Path $PSCommandPath -raw
$item2 = Invoke-WebRequest -Uri "$($config.remote)/launcher/launch.ps1"
if ($item1 -eq $item2) {
Write-Host "Up to date" -ForegroundColor $clrSuccess
} else {
Write-Host "New version available" -ForegroundColor $clrWarn
invoke-expression "./update.ps1 $($config.remote)"
exit
}
}