• Site for Newbie Windows Administrators
admincentric
  • Home
  • Active Directory
  • Hyper-V
  • PowerShell
  • Free Tools
  • Contact

PowerShell -ne Operator

Feb 09, 2024 Admin

In PowerShell, the `-ne` operator is used for comparison and stands for "not equal." It is used to compare two values and return `True` if they are not equal, and `False` if they are equal. The `-ne` operator is case-insensitive, meaning it does not consider the case of the values being compared.

The syntax for -ne operator is:

$value1 -ne $value2

`$value1` and `$value2` are the two values you want to compare.

Here are a few examples to illustrate how the `-ne` operator works:


Example 1

5 -ne 10

In this example, `5` is not equal to `10`, so the result is `True`.


Example 2

"Hello" -ne "hello"

In this example, the strings "Hello" and "hello" are not equal because the `-ne` operator is case-insensitive. Therefore, the result is `False`.


Example 3

$name1 = "John"
$name2 = "Jane"
$name1 -ne $name2

Here, the values stored in the variables `$name1` and `$name2` are not equal, so the result is `True`.

You can also use the `-ne` operator in conditional statements, loops, and other parts of your PowerShell scripts to make decisions based on whether two values are not equal.

Home

Active Directory

Hyper-V

PowerShell

Free Tools

Contact

Trending News

How to enable Hyper-V in Windows? Coming Soon...

How to configure a Virtual Machine? Coming Soon...

Using PowerShell to manage a Virtual Machine Coming Soon...

How to install Active Directory on Windows Server 2016? Coming Soon...

How to create Active Directory Users? Coming Soon....

How to reset Active Directory User Passwords? Coming Soon...

How to unlock Active Directory User Accounts? Coming Soon...

Popular Resources

Popular resource 1 coming soon....coming soon

Popular resource 1 coming soon....coming soon

Popular resource 1 coming soon....coming soon

Popular resource 1 coming soon....coming soon

Table of Contents

Table of Contents

  • Syntax
  • Example 1
  • Example 2
  • Example 3

Connect with us!

Company
  • About admincentric
  • Advertise with us
  • Contact
Pages
  • Webinars
  • Deals Store
  • Privacy Policy
Deals
  • Hacking
  • Development
  • Android
RSS Feeds Contact Us

© admincentric, 2023. All Rights Reserved.