Using the -replace Operator in PowerShell
📖 Scenario: You work in a small office where you keep a list of employee email addresses. Some emails have an old domain that needs to be updated to a new domain.
🎯 Goal: You will create a list of email addresses, set the old domain to replace, use the -replace operator to update the emails, and then display the updated list.
📋 What You'll Learn
Create a list of email addresses with exact values
Create a variable for the old domain string
Use the
-replace operator to update the domain in all emailsPrint the updated list of email addresses
💡 Why This Matters
🌍 Real World
Updating email domains is common when companies rebrand or merge. Automating this saves time and avoids mistakes.
💼 Career
Knowing how to use the <code>-replace</code> operator helps in scripting tasks for system administration and data cleanup.
Progress0 / 4 steps