What will be the output of the following PowerShell command using AWS Tools for PowerShell?
Get-EC2Instance -InstanceIds 'i-1234567890abcdef0' | Select-Object -ExpandProperty Instances | Select-Object InstanceId, State
Get-EC2Instance -InstanceIds 'i-1234567890abcdef0' | Select-Object -ExpandProperty Instances | Select-Object InstanceId, StateConsider what the -ExpandProperty parameter does in PowerShell and how AWS cmdlets return data.
The Get-EC2Instance cmdlet returns an object containing a property Instances which is a list of instance objects. Using -ExpandProperty Instances extracts that list so you can select properties like InstanceId and State directly.
Which of the following commands correctly sets AWS credentials for the current PowerShell session using AWS Tools for PowerShell?
Look for the cmdlet that explicitly sets credentials and optionally stores them under a profile name.
Set-AWSCredential is the correct cmdlet to set AWS credentials in the current session and optionally save them under a profile name for reuse.
You want to write a PowerShell script using AWS Tools for PowerShell to delete all EC2 instances with a specific tag key-value pair. Which approach below correctly lists and deletes only those instances?
Think about how AWS cmdlets accept filters and how deletion cmdlets require instance IDs.
Get-EC2Instance supports filtering by tags to list matching instances. Remove-EC2Instance requires instance IDs to delete. So first filter, then delete by IDs.
Which practice below is the most secure way to handle AWS credentials in PowerShell scripts for automation?
Consider AWS best practices for credential management in automated environments.
Using IAM roles attached to the compute environment (like EC2 or Lambda) allows automatic, secure credential management without embedding secrets in scripts.
In what order does the AWS Tools for PowerShell module resolve credentials when executing a cmdlet?
Think about the precedence of credentials explicitly provided versus environment or role-based credentials.
The AWS Tools for PowerShell first use credentials explicitly passed to the cmdlet, then environment variables, then the shared credentials file (~/.aws/credentials), and finally IAM roles if running on AWS compute resources.