Jump to content

Recommended Posts

Posted (edited)

I'm new to powershell, but am trying to evaluate a statement and getting results I don't understand. I find that my variable = True. Then when I write an if statement to evaluate if something is "True" I get a yes answer.

 

PS U:\> $pathexists

True

PS U:\> if ($pathexists -eq "True") {"It was True"}

It was True

PS U:\> if ($pathexists -eq "False") {"It was also False!"}

It was also False!

PS U:\> $pathexists

True

 

Why in the world would ($pathexists -eq "False") wind up evaluating as if they were equal, when my variable is clearly True?

Edited by goaliepride
fixed
Posted
This wound up being a problem of statements I think. true/false should be written $true/$false, who knew something that looked like a variable was a constant?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...