Bird
0
0

What will be the output of this command?

medium📝 Command Output Q4 of 15
PowerShell - Remote Management
What will be the output of this command?
Invoke-Command -ComputerName localhost -ScriptBlock { 7 * 6 }
ANothing, command runs silently
B7 * 6
CError: Expression not valid
D42
Step-by-Step Solution
Solution:
  1. Step 1: Understand the script block

    The script block contains the expression 7 * 6, which evaluates to 42.
  2. Step 2: Invoke-Command runs the script block and returns the result

    Since the command runs on localhost, it executes and returns the numeric result.
  3. Step 3: Evaluate other options

    7 * 6 is the literal string, which is not returned; Error: Expression not valid is incorrect as the expression is valid; Nothing, command runs silently is wrong because output is returned.
  4. Final Answer:

    42 -> Option D
  5. Quick Check:

    Invoke-Command returns evaluated script block output [OK]
Quick Trick: Invoke-Command returns evaluated script block output [OK]
Common Mistakes:
  • Expecting the script block text instead of result
  • Assuming no output is returned
  • Thinking it throws an error for simple math

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes