Q: Executing $true statement when $false I am having a bit of trouble with a PowerShell script. The intent of this is to spider the network and look for files/folders that exist on any PC. 
Here is the original source:
#FiToFin Script#
$Fltr = "how_recover*.*"
$Online = "C:\Users\<username>\Scripts\Logs\Online.log"
$CSV = "C:\Users\<username>\Scripts\Devices.csv"
#$Tstpath = test-path "\\$computer\c$"
$Offline = "C:\Users\<username>\Scripts\Logs\Offline.log"
##################################################
$devices = Get-Content "$CSV"
foreach ($computer in $devices) {
  Test-Path "\\$computer\c$" > $Tstpath
  if ($Tstpath -eq $True) {
    ls -Path "\\$computer\c$\users" -Filter $Fltr -Recurse |
      Out-File -Append $Online
  } else {
    Write-Host "$computer is NOT Online" | Out-File -Append $Offline
  }
}
##################################################
Write-Host "_____________________"
Write-Host "Online file = $Online"
Write-Host "Offile file = $Offline"
Write-Host "_____________________"

I have changed the if statement to if($Tstpath -eq "True"), if ($lastexitcode -eq $true) and if($Tstpath -eq $false) and they all just parse the first {Do command} no matter what. They never drop into else. Even tried the Tstpath = Test-Path \\$computer\c$ as a variable and just running that. 
When it parses the first {Do Command} the return is
ls : Cannot find path '\\<computerName>\c$\u' because it does not exist.
At C:\Users\<username>\Scripts\FiToFin.ps1:19 char:3
+         ls -Path "\\$computer\c$\users" -Filter $Fltr -Recurse | Out-File -Append $On ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (\\<computername>\c$\u:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

What does work:
If my test machines are on I can ls -Path "\\$computer\c$\users" -Filter $Fltr -Recurse | Out-File -Append $Online just fine.
I get True or False from Test-Path \\$computer\c$ and can even > $var and Write-Host the results just fine. 
I have no idea why this is and would love to know. 
This also works:
###################################################################
$computer = "TestPC"
$Tstpath = Test-Path \\$computer\c$
####################################################################
$Tstpath > $null
if($Tstpath -eq $True) {
    Write-Host "$computer is Online"
} else {
    Write-Host "$computer is NOT Online"
}

But when you add the command ls or Get-ChildItem it freaks out.
So, question is: Why is it never executing the else portion?

A: I see two issues that would be causing your issues. How you initialize and update the variable $Tstpath
# Presumably Initialize
$Tstpath = test-path "\\$computer\c$"

# Updating in loop
test-path "\\$computer\c$" > $Tstpath

I will assume that you are testing in PowerShell ISE and that $Tstpath had a $true value at some point. 
The issue is that you were never updating the variable. Looking at TechNet for about_redirection you will see that:

   Operator  Description               Example  
   --------  ----------------------    ------------------------------
   '>'       Sends output to the       Get-Process > Process.txt
                specified file.


Your command was trying to output that to "file". You should have had an error about not being able to find the file or a file somewhere on your system with a  single boolean in it (since it was not an append redirector). 
What you should have done to stay with your logic is save the result via assignment.
$Tstpath = Test-path "\\$computer\c$"

Then you can test that. 
However it is redundant since you do not ever need that value again. Would just be easier to put it straight in the if statement. 
if(test-path "\\$computer\c$"){"Do something"}else{"Fail Trumpet"}

I would also suggest using Export-CSV -Append since you are dealing with objects. Would make for good structured output. 
Get-ChildItem -path "\\$computer\c$\users\" -Filter $Fltr -Recurse | Export-CSV -Append $Online -NoTypeInformation

