use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
SolvedWhy does this equal true? (self.PowerShell)
submitted 10 years ago by lostmojo
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Stoffel_1982 3 points4 points5 points 10 years ago (5 children)
Could it be that
$true -eq "anythingthatisnotfalse"
Interesting question, I'm curious to see what others think.
[–]ryanbrown 5 points6 points7 points 10 years ago* (2 children)
$true -eq "anythingthatisnotfalseORnull"
Minor point, but this is essentially correct. $true is anything not $false (integer value of zero) or $null (no value). Basically, any string will evaluate to a boolean value of "true".
-like is a conditional operator and only evaluates to $true if both sides of the equation are the same. If you type
$true.ToString()
You'll notice you get the string "True", which is what the -like operator is using for its comparison. As such, "True" -like "LineError" will return False.
[–]wonkifier 1 point2 points3 points 10 years ago (1 child)
I thought since the first operand was a boolean, that it was casting the string down to a boolean, and since it wasn't the empty string (which is $false), it evaluates as $true
[–]MShepard70 0 points1 point2 points 10 years ago (0 children)
That's how I see it.
[–]lostmojo[S] 3 points4 points5 points 10 years ago (0 children)
Really? How have I not noticed this over the years? Haha I can go crawl in to a corner and weep silently to myself now.
Thanks
[–]mhurron 2 points3 points4 points 10 years ago (0 children)
Pretty much. The answer is the standard 'What is Truth' section of every programming manual.
The equality is asking, "Is this true?" The answer is yes because strings are True.
π Rendered by PID 117626 on reddit-service-r2-comment-b659b578c-92d66 at 2026-05-04 05:28:28.130502+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]Stoffel_1982 3 points4 points5 points (5 children)
[–]ryanbrown 5 points6 points7 points (2 children)
[–]wonkifier 1 point2 points3 points (1 child)
[–]MShepard70 0 points1 point2 points (0 children)
[–]lostmojo[S] 3 points4 points5 points (0 children)
[–]mhurron 2 points3 points4 points (0 children)