Are you wondering how to compare values in PowerShell to see if they’re greater than or equal? You can do this by using the -ge operator in PowerShell. In this tutorial, I will explain everything you need to know about using “greater than or equal” in PowerShell. You will see some real examples.
What Is the PowerShell Greater Than or Equal Operator?
In PowerShell, the -ge operator is used to compare two values, returning True if the value on the left is greater than or equal to the value on the right. This operator works with numbers, strings, and even dates, making it a versatile tool in your scripting toolkit.
Key Points:
- Operator:
-ge - Stands for: Greater than or equal to
- Returns: Boolean (
TrueorFalse) - Works with: Numbers, strings, dates, arrays
Check out PowerShell Match Operator Examples
Basic Syntax and Usage
The syntax for using the -ge operator in PowerShell is easy. You place it between two values or variables you wish to compare.
$value1 -ge $value2This command evaluates to True if $value1 is greater than or equal to $value2, and False otherwise. This simplicity is why I use it daily when filtering data or validating user input.
PowerShell Greater Than or Equal Example
Now, let me show you a real example of PowerShell greater than or equal.
Let’s say I have a list of employees in New York and I want to find everyone making at least $100,000 per year.
First, I’ll create an array of employee objects, each with a Name, City, and Salary. Then, I’ll use Where-Object with the -ge operator to filter those with a salary greater than or equal to $100,000.
Below is the complete PowerShell script.
$employees = @(
[PSCustomObject]@{ Name = "Jessica Smith"; City = "New York"; Salary = 120000 }
[PSCustomObject]@{ Name = "Michael Johnson"; City = "Chicago"; Salary = 95000 }
[PSCustomObject]@{ Name = "David Lee"; City = "Los Angeles"; Salary = 105000 }
[PSCustomObject]@{ Name = "Emily Davis"; City = "Houston"; Salary = 99000 }
)
$highEarners = $employees | Where-Object { $_.Salary -ge 100000 }
$highEarnersThis script filters only those employees whose salary is at least $100,000. The -ge operator makes the comparison clear and concise, and PowerShell’s pipeline makes it easy to process lists like this. This approach is particularly effective in HR and payroll automation scenarios.
You can see the exact output in the screenshot below:

Check out PowerShell Filter Operators
Using Greater Than or Equal with Numbers
Comparing numbers is the most common use for -ge. Whether you’re checking server uptime, disk space, or user counts, you’ll use this operator often.
Here is an example.
$serverUptime = 45 # in days
if ($serverUptime -ge 30) {
Write-Host "Server has met the 30-day uptime compliance requirement."
} else {
Write-Host "Server has NOT met the compliance requirement."
}Here, the script checks if the server has been up for at least 30 days. If so, it confirms compliance. This is a typical use case in IT audits and system monitoring.
Here is the exact output in the screenshot below:

Read PowerShell Arithmetic Operators
Comparing Strings Alphabetically
PowerShell can compare strings using -ge, based on alphabetical order (lexical comparison). This is useful when sorting or filtering data, such as U.S. state names.
Here is an example.
$state = "Texas"
if ($state -ge "Oregon") {
Write-Host "$state comes after or is the same as Oregon alphabetically."
} else {
Write-Host "$state comes before Oregon alphabetically."
}The -ge operator compares the Unicode values of the strings. In this example, “Texas” comes after “Oregon,” so the condition is True. This is handy for sorting or filtering lists alphabetically in scripts.
Compare Dates and Times
You can use -ge to compare dates, which is extremely useful for log analysis or compliance checks (e.g., ensuring backups are recent).
Here is an example.
$backupDate = Get-Date "2025-06-30"
$complianceDate = Get-Date "2025-06-01"
if ($backupDate -ge $complianceDate) {
Write-Host "Backup is compliant."
} else {
Write-Host "Backup is outdated."
}This script checks if the backup date is on or after the compliance date. PowerShell handles date comparison natively, making it easy to automate time-sensitive checks.
Check out PowerShell Logical Operators
Using -ge in Arrays and Loops
When processing data in bulk, such as lists of U.S. cities or population numbers, you can use -ge in loops or with Where-Object for efficient filtering.
Here is an example and the PowerShell script.
$cityPopulations = @{
"New York" = 8419000
"Los Angeles" = 3980000
"Chicago" = 2716000
"Houston" = 2328000
}
$largeCities = $cityPopulations.GetEnumerator() | Where-Object { $_.Value -ge 3000000 }
$largeCitiesThis script finds all U.S. cities in the hash table with populations of 3 million or more. Using -ge inside Where-Object is my go-to method for data filtering in PowerShell.
Check out PowerShell Comparison Operators
Case-Sensitive Comparisons
If you need case-sensitive comparisons (rare, but sometimes required), PowerShell provides the -cge operator.
Here is an example.
$city1 = "Dallas"
$city2 = "dallas"
if ($city1 -cge $city2) {
Write-Host "Case-sensitive comparison: $city1 is greater than or equal to $city2."
} else {
Write-Host "Case-sensitive comparison: $city1 is less than $city2."
}Here, -cge checks the case as well, so “Dallas” is not equal to “dallas”. This can be useful in security scripts or when processing case-sensitive data.
PowerShell Comparison Operators Reference Table
| Operator | Meaning | Example | Result |
|---|---|---|---|
| -eq | Equal to | 5 -eq 5 | True |
| -ne | Not equal to | 5 -ne 3 | True |
| -gt | Greater than | 7 -gt 5 | True |
| -ge | Greater than or equal to | 5 -ge 5 | True |
| -lt | Less than | 3 -lt 7 | True |
| -le | Less than or equal to | 3 -le 3 | True |
Best Practices and Tips
- Always use
-geinstead of>=: PowerShell uses-gefor comparisons, not the typical>=found in other languages. - Be mindful of data types: Ensure you’re comparing like types (e.g., don’t compare a string to a number).
- Use with
Where-Objectfor filtering: This is the most efficient way to filter collections and arrays. - Test with real data: Always validate your scripts with real-world data to avoid surprises in production.
Conclusion
The PowerShell greater than or equal operator, -ge, is used for comparisons, filtering, etc. Whether you’re working with numbers, strings, dates, or arrays, -ge gives you the flexibility to use it according to the requirement.
You may also like the following tutorials:
- PowerShell Not Operator
- How to Use -and Operator in PowerShell?
- PowerShell -contains Operator [With Examples]
- PowerShell Like Operator
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.