Consider:
function func {
echo ALERT
return $false
}
if (func) {
Write-Output "TRUE"
}
This code writes TRUE despite the function returning false. However, when I write [void]echo ALERT, PowerShell throws an error:
Unexpected token 'echo' in expression or statement.
How do I fix this code?