Something is really weird with this language. I\'m trying to execute a function and use its result value as condition. This is my code:
function Get-Platform
I think you are comparing a function and not the function result. Also somehow the echo does not work as expected in a function. I usually use Write-Host.
Here is my solution to your problem:
function Get-Platform()
{
# Determine current Windows architecture (32/64 bit)
if ([System.Environment]::GetEnvironmentVariable("ProgramFiles(x86)") -ne $null)
{
Write-Host("x64")
return "x64"
}
else
{
Write-Host("x86")
return "x86"
}
}
$platform = Get-Platform
if ($platform -eq 'x64')
{
echo "64 bit platform"
}
if ($platform -eq 'x86')
{
echo "32 bit platform"
}