PowerShell - Variables and Data TypesYou want to store a user's age and then increase it by 1. Which script correctly updates the variable?A$age = 30 $age = $age + 1 Write-Output $ageB$age = 30 $age + 1 Write-Output $ageC$age = 30 Add 1 to $age Write-Output $ageD$age = 30 $age += Write-Output $ageCheck Answer
Step-by-Step SolutionSolution:Step 1: Check how variable is updated$age = 30 $age = $age + 1 Write-Output $age correctly adds 1 and assigns back to $age.Step 2: Verify output commandWrite-Output prints updated $age value, which will be 31.Final Answer:$age = 30 $age = $age + 1 Write-Output $age -> Option AQuick Check:Proper variable update uses assignment after addition [OK]Quick Trick: Add and assign back to variable to update value [OK]Common Mistakes:Adding without assignmentUsing invalid syntax like 'Add 1 to $age'Incomplete operators like '+=' without value
Master "Variables and Data Types" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Cmdlets and Pipeline - Where-Object for filtering - Quiz 1easy Control Flow - If-elseif-else statements - Quiz 12easy Control Flow - For loop - Quiz 2easy Control Flow - Why control flow directs execution - Quiz 4medium PowerShell Basics and Environment - First PowerShell command - Quiz 9hard String Operations - Regular expressions with -match - Quiz 15hard String Operations - Formatting with -f operator - Quiz 8hard String Operations - Here-strings for multiline - Quiz 8hard Variables and Data Types - String type and interpolation - Quiz 14medium Variables and Data Types - Type casting - Quiz 13medium