Using the match operator in PowerShell
📖 Scenario: You work in a small office where you receive messages from different departments. Each message starts with a keyword like 'Sales', 'HR', or 'IT'. You want to quickly check the type of message and print a response.
🎯 Goal: Create a PowerShell script that uses the match operator to check the message type and print a matching response.
📋 What You'll Learn
Create a variable
$message with a specific message stringCreate a variable
$keyword to hold the first word of the messageUse the
match operator to compare $keyword with known departmentsPrint the correct response based on the matched keyword
💡 Why This Matters
🌍 Real World
This script helps quickly identify message types in office communication for faster processing.
💼 Career
Using the match operator is useful for filtering logs, processing text, and automating responses in IT and administrative jobs.
Progress0 / 4 steps