Using Logical Operators in PowerShell
📖 Scenario: You are managing a list of employees and their work statuses. You want to check who is eligible for a bonus based on their attendance and performance.
🎯 Goal: Build a PowerShell script that uses logical operators -and and -not to filter employees based on their attendance and performance.
📋 What You'll Learn
Create a dictionary called
employees with employee names as keys and a nested dictionary as values containing attendance and performance scores.Create a variable called
attendance_threshold set to 80.Use a
foreach loop with variables name and info to iterate over employees.GetEnumerator().Inside the loop, use logical operators
-and and -not to check if an employee's attendance is above the threshold and performance is good.Print the names of employees who qualify for the bonus.
💡 Why This Matters
🌍 Real World
Filtering employee data based on multiple conditions is common in HR and management tasks to decide bonuses or promotions.
💼 Career
Understanding logical operators and loops in PowerShell helps automate administrative tasks and data filtering in IT and business roles.
Progress0 / 4 steps