PS
Powershell Tutorial Online

Powershell If Else

Similar to programming language, in powershell, if condition will check the given condition and if it is true,
it will execute the statements within the first set of braces(from '{' to the next '}').
If the condition is not true, it will check the next condition and so on.
If no given condition is true, the 'else' statements are executed.


Here is the list of all comparing operator with examples.


Operator Description
-eq Equal to
-lt Less than
-gt Greater than
-ge Greater than or Eqaul to
-le Less than or equal to
-ne Not equal to

When comparing text strings, by default PowerShell is not case-sensitive.
But here we have another option to force case-sensitivity.
By appending an "i" to the any operator, you can force PowerShell to be "case-insensitive."
Appending a "c" you can force PowerShell to compare as "case-sensitive."



Use of if else. Only if statement is required, everything else is optional. Powershell doent care of spaces, position of "{" and "}" and formatting. There is not limitation on elseif statements.