Bird
0
0

Why might this command fail?

medium📝 Debug Q7 of 15
PowerShell - Remote Management
Why might this command fail?
Invoke-Command -ComputerName Server01 -ScriptBlock { Get-Content C:\secret.txt } -Credential $null
AGet-Content cannot be run remotely
BPassing $null as credential causes authentication failure
CThe script block syntax is invalid
DInvoke-Command does not support the -Credential parameter
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the use of -Credential

    Passing $null explicitly as a credential causes authentication to fail because no valid credentials are provided.
  2. Step 2: Check other options

    Get-Content can run remotely inside script blocks; the script block syntax is valid; -Credential is supported.
  3. Final Answer:

    Passing $null as credential causes authentication failure -> Option B
  4. Quick Check:

    Null credentials cause authentication failure [OK]
Quick Trick: Null credentials cause authentication failure [OK]
Common Mistakes:
  • Assuming Get-Content cannot run remotely
  • Thinking script block syntax is wrong
  • Believing -Credential is unsupported

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes