Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.


Go Back   Vista Forums > Misc Newsgroups > PowerShell

RB

Vista - What is the difference between -eq and =

Reply
 
12-10-2008   #1
Jacob Sampson


 
 

What is the difference between -eq and =

I had a script that looked to see if $count = 0. It did not work until I
tried $count
-eq 0

What is the difference?

My System SpecsSystem Spec
12-10-2008   #2
Kiron


 
 

Re: What is the difference between -eq and =

'=' is an assignment operator, assigns a value to a variable or property
'-eq' is a comparison operator, cheks for equality

--
Kiron
My System SpecsSystem Spec
12-10-2008   #3
Vadims Podans


 
 

Re: What is the difference between -eq and =

When you write $count = 0, PowerShell provide new value assignment to
variable, but not value comparing. If you want to compare, has variable
appropriate value or not, you must to use comparison operators
( -eq, -ne, -le, etc). Similar behaviour is in C++ language (when you
compare variable value, then you must use double assignment operator: if
variable == 0 ...).

--
WBR, Vadims Podans
PowerShell blog - www.sysadmins.lv

"Jacob Sampson" <JacobSampson@xxxxxx> rakstīja ziņojumā
"news:52AA9171-4E76-4C00-8447-73671C4F81B4@xxxxxx"...
Quote:

> I had a script that looked to see if $count = 0. It did not work until I
> tried $count
> -eq 0
>
> What is the difference?
My System SpecsSystem Spec
Reply

RB


Thread Tools


Similar Threads for: What is the difference between -eq and =
Thread Forum
Difference between 32-bit and 64-bit General Discussion
I can't believe the difference Vista General
What is the difference Vista music pictures video
What is the difference? Vista General
What is the difference between Pre-RC1 and RC1? Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
Designer Media Ltd