Bird
0
0

You want to list all EC2 instances in the 'us-east-1' region using AWS PowerShell. Which command correctly sets the region and retrieves the instances?

hard📝 Application Q15 of 15
PowerShell - Cross-Platform PowerShell
You want to list all EC2 instances in the 'us-east-1' region using AWS PowerShell. Which command correctly sets the region and retrieves the instances?
ASet-DefaultAWSRegion -Region us-east-1; Get-EC2Instance
BGet-EC2Instance -RegionName us-east-1
CSet-AWSRegion us-east-1; Get-EC2Instance
DGet-EC2Instance | Where-Object { $_.Region -eq 'us-east-1' }
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to set AWS region in PowerShell

    The cmdlet to set default region is Set-DefaultAWSRegion with -Region parameter.
  2. Step 2: Retrieve EC2 instances after setting region

    After setting region, Get-EC2Instance fetches instances in that region. Set-DefaultAWSRegion -Region us-east-1; Get-EC2Instance correctly chains these commands.
  3. Step 3: Evaluate other options

    Get-EC2Instance -RegionName us-east-1 uses invalid parameter '-RegionName'; Set-AWSRegion us-east-1; Get-EC2Instance uses a non-existent cmdlet; Get-EC2Instance | Where-Object { $_.Region -eq 'us-east-1' } filters instances locally but region info is not a direct property.
  4. Final Answer:

    Set-DefaultAWSRegion -Region us-east-1; Get-EC2Instance -> Option A
  5. Quick Check:

    Set region first, then get instances [OK]
Quick Trick: Set region with Set-DefaultAWSRegion before commands [OK]
Common Mistakes:
  • Using wrong cmdlet to set region
  • Passing -Region directly to Get-EC2Instance
  • Filtering region locally without setting it

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes