Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import users from a CSV file.
PowerShell
Import-Csv [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names like -File or -Input.
Not enclosing the file name in quotes.
✗ Incorrect
The Import-Csv cmdlet uses the -Path parameter to specify the CSV file location.
2fill in blank
mediumComplete the code to loop through each user imported from CSV.
PowerShell
foreach ($user in [1]) { Write-Output $user.Name }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Get-Content which reads raw text lines, not objects.
Using a variable not defined before the loop.
✗ Incorrect
You can directly loop through the output of Import-Csv to process each user.
3fill in blank
hardFix the error in the code to create a new user from CSV data.
PowerShell
New-ADUser -Name $user.Name -SamAccountName $user.[1] -AccountPassword (ConvertTo-SecureString $user.Password -AsPlainText -Force) -Enabled $true Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names that do not match CSV headers.
Ignoring case sensitivity in property names.
✗ Incorrect
The property name is case-sensitive and should be 'UserName' to match the CSV header.
4fill in blank
hardFill both blanks to filter users with 'Admin' in their role and create them.
PowerShell
Import-Csv 'users.csv' | Where-Object { $_.Role [1] '*Admin*' } | ForEach-Object { New-ADUser -Name $_.Name -SamAccountName $_.UserName -UserPrincipalName $_.UserPrincipalName -AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -Force) -Enabled [2] }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-eq' which requires exact match instead of pattern match.
Setting -Enabled to $false which disables the account.
✗ Incorrect
Use '-like' to match roles containing 'Admin' and enable the account with $true.
5fill in blank
hardFill all three blanks to update user email and enable the account only if status is 'Active'.
PowerShell
Import-Csv 'users.csv' | ForEach-Object { if ($_.Status [1] 'Active') { Set-ADUser -Identity $_.UserName -EmailAddress $_.[2] -Enabled [3] } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-ne' or other operators instead of '-eq'.
Using wrong property names like 'EmailAddress' if CSV uses 'Email'.
Setting -Enabled to $false which disables the user.
✗ Incorrect
Use '-eq' to check status, update 'Email' property, and enable account with $true.