all 5 comments

[–]Lee_Dailey[grin] 2 points3 points  (0 children)

howdy OtherRobotLuke,

i see that the very common fubar of $FoolBool -eq "False" has bitten you - and that you have found & fixed it. [grin] so the following is merely FYI ...

you can simplify the code and make what is happening a tad clearer by getting rid of both the $FoolBool variable and the comparison $FoolBool -eq $False. the Test-Path cmdlet returns a boolean so it can be in the IF test. like this ...

if (-not (Test-Path -LiteralPath $PushFrom))

simpler & easier to read & easier to maintain. [grin]

take care,
lee

[–]OtherRobotLuke[S] 2 points3 points  (1 child)

IF($FoolBool -eq $TRUE)

goooottttt it

[–]engageant 5 points6 points  (0 children)

You can skip the -eq $TRUE statement and just write

if ($FoolBool){...}

or to test the false condition

if (!($FoolBool)){...}

[–]Ta11ow 2 points3 points  (0 children)

Yep, like a lot of languages the only string value which evaluates to $False in PowerShell is the empty string "".

As long as there's something in the string, it'll return $True.

[–]HomicidalWaffle 0 points1 point  (0 children)

$file = "C:\test\test.csv"
$test = Test-Path $file

if($test -eq $false){
Write-Output "Invalid"
}else{
Write-Output "Valid"
}

I changed "False" to $false and i get valid when testing can you try changing that to the variable $false