PowerShell - FunctionsWhich of the following is the correct way to define a parameter with a default value of 5 in a PowerShell function?Aparam([int]$count : 5)Bparam([int]$count => 5)Cparam([int]$count <- 5)Dparam([int]$count = 5)Check Answer
Step-by-Step SolutionSolution:Step 1: Recall PowerShell parameter default syntaxPowerShell uses '=' to assign default values in param blocks.Step 2: Check each optionOnly param([int]$count = 5) uses '=' correctly; others use invalid symbols.Final Answer:param([int]$count = 5) -> Option DQuick Check:Default value syntax = '=' [OK]Quick Trick: Use '=' to assign default values in param block [OK]Common Mistakes:Using ':' or '=>' instead of '='Confusing syntax with other languagesOmitting the '=' sign
Master "Functions" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Functions - Advanced functions (CmdletBinding) - Quiz 10easy Functions - Advanced functions (CmdletBinding) - Quiz 12easy Functions - Why functions organize scripts - Quiz 4medium Modules and Script Organization - Module manifest (.psd1) - Quiz 8hard Modules and Script Organization - Module manifest (.psd1) - Quiz 2easy Regular Expressions - Named captures - Quiz 12easy Regular Expressions - Regex with Select-String - Quiz 13medium Regular Expressions - Named captures - Quiz 11easy Regular Expressions - Named captures - Quiz 1easy Working with Objects - Measure-Object for statistics - Quiz 10hard