Bird
0
0

You run this script in PowerShell on Linux:

medium📝 Debug Q14 of 15
PowerShell - Cross-Platform PowerShell
You run this script in PowerShell on Linux:
pwsh
$process = Get-Process -Name "bash"
Write-Output $process.Id
But it returns an error: "Get-Process: The term 'Get-Process' is not recognized." What is the likely cause?
APowerShell is not installed correctly on Linux
BYou are running the script in the Linux shell, not inside PowerShell
CThe process 'bash' does not exist
DGet-Process cmdlet is not available on Linux PowerShell
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the error message

    The error says 'Get-Process' is not recognized, which usually means the command is run outside PowerShell.
  2. Step 2: Understand environment context

    If you run PowerShell commands in the Linux shell (bash), they won't work. You must be inside PowerShell (started with pwsh) to run Get-Process.
  3. Final Answer:

    You are running the script in the Linux shell, not inside PowerShell -> Option B
  4. Quick Check:

    Run PowerShell cmdlets inside pwsh shell [OK]
Quick Trick: Run PowerShell commands only inside pwsh shell, not bash [OK]
Common Mistakes:
  • Assuming Get-Process is missing on Linux PowerShell
  • Thinking the process 'bash' does not exist
  • Not starting PowerShell before running commands

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes