0
0
PowerShellscripting~30 mins

Bulk user operations from CSV in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Bulk user operations from CSV
📖 Scenario: You are an IT assistant who needs to update user accounts in bulk using data from a CSV file. The CSV contains usernames and their new email addresses. You want to automate this task using PowerShell to save time and avoid mistakes.
🎯 Goal: Create a PowerShell script that reads user data from a CSV file, filters users based on a condition, updates their email addresses, and displays the updated information.
📋 What You'll Learn
Create a variable to import CSV data with exact filename 'users.csv'
Create a variable called 'emailDomain' with the value '@example.com'
Use a loop to find users whose username starts with 'user' and update their email
Print the updated user list showing username and new email
💡 Why This Matters
🌍 Real World
Automating bulk updates of user accounts from CSV files is common in IT departments to save time and reduce manual errors.
💼 Career
This skill is useful for system administrators, IT support staff, and anyone managing user data in organizations.
Progress0 / 4 steps
1
Import CSV data
Create a variable called users that imports data from the CSV file named users.csv using Import-Csv.
PowerShell
Need a hint?

Use Import-Csv -Path 'users.csv' to read the CSV file into a variable.

2
Set email domain configuration
Create a variable called emailDomain and set it to the string '@example.com'.
PowerShell
Need a hint?

Just assign the string '@example.com' to the variable emailDomain.

3
Update user emails based on username
Use a foreach loop with variable user to go through $users. Inside the loop, check if $user.username starts with 'user'. If yes, update $user.email to be $user.username plus $emailDomain.
PowerShell
Need a hint?

Use foreach ($user in $users) and inside check $user.username.StartsWith('user'). Then update $user.email.

4
Display updated users
Use foreach with variable user to loop over $users and print the username and email in the format: Username: [username], Email: [email] using Write-Output.
PowerShell
Need a hint?

Loop through $users and use Write-Output to print username and email in the required format.