Hi All, I'm trying to run what should be a simple powershell script I'm having a difficult time getting it to run as expected in SAM. Seems like SAM is always evaluating true even when the condition is false.
Wondering if anyone can look at my code and tell me if they see an issue.
Thanks all :
$Server=${IP};
$var1=w32tm /query /computer:$Server /status | Select-String -pattern "Local CMOS Clock";
$var2=($var1 -split ':')[1];
Write-Host "Test against IP $Server=${IP}";
echo $var2;
if($var2.Trim() -eq "Local CMOS Clock"){
Write-Host "SUCCESS";
Write-Host "Statistic: 0";
exit 0;
}Else{
Write-Host "UNSUCCESSFUL";
Write-Host "Statistic: 0";
exit 1;
}