Bird
0
0

Which of the following is the correct syntax to check the PowerShell version in both 5.1 and 7+?

easy📝 Syntax Q3 of 15
PowerShell - Basics and Environment
Which of the following is the correct syntax to check the PowerShell version in both 5.1 and 7+?
A$PSVersionTable.PSVersion.Major
BGet-PSVersion
Cversion.ps
DCheck-PowerShellVersion
Step-by-Step Solution
Solution:
  1. Step 1: Identify the standard variable for version info

    $PSVersionTable is a built-in variable holding version details in all PowerShell versions.
  2. Step 2: Access the major version property

    Using $PSVersionTable.PSVersion.Major returns the major version number correctly.
  3. Final Answer:

    $PSVersionTable.PSVersion.Major -> Option A
  4. Quick Check:

    Version check syntax = $PSVersionTable.PSVersion.Major [OK]
Quick Trick: Use $PSVersionTable.PSVersion.Major to get major version [OK]
Common Mistakes:
  • Using non-existent commands
  • Trying to run version.ps file
  • Assuming Get-PSVersion exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes