aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
239 stars 79 forks source link

Get-AWSCmdletName does not always return results when wildcards are used #113

Closed techthoughts2 closed 4 years ago

techthoughts2 commented 4 years ago

The Get-AWSCmdletName with the CmdletName parameter sometimes works when wildcards are specified, but sometimes it does not.

Expected Behavior

Get-AWSCmdletName -CmdletName "*SQS*"

Returns list of all AWS cmdlets with SQS in the cmdlet name

Current Behavior

Works for things like S3:

Get-AWSCmdletName -CmdletName "*s3*"

CmdletName                                       ServiceOperation                             ServiceName
----------                                       ----------------                             -----------
Get-ASYNSchemaCreationStatus                     GetSchemaCreationStatus                      AWS AppSync
Resume-ASProcess                                 ResumeProcesses                              AWS Auto Scaling
Suspend-ASProcess                                SuspendProcesses                             AWS Auto Scaling

Does not work for SQS:

Get-AWSCmdletName -CmdletName "*SQS*"

Possible Solution

There are several ways this could be solved but adjusting the behavior of this seems like a good start:

https://github.com/aws/aws-tools-for-powershell/blob/7d148285dbd8e0e465f4b5ceccc4053b82b763e2/modules/AWSPowerShell/Common/DiscoveryCmdlets.cs#L313

If the MatchWithRegex can't be adjusted a -like parameter could be added to provide that experience.

Steps to Reproduce (for bugs)

Run the following command:

Get-AWSCmdletName -CmdletName "*SQS*"

Context

When trying to get a list of available cmdlets for a given technology (SQS) I will often wild-card search the technology name. Than I can select the correct cmdlet.

The current behavior enables this sometimes, but other times it does not work. This affects my ability to quickly identify the correct cmdlets I need.

Your Environment

AWS.Tools

Get-AWSPowerShellVersion

AWS Tools for PowerShell
Version 4.0.2.0
Copyright 2012-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Amazon Web Services SDK for .NET
Core Runtime Version 3.3.104.4
Copyright 2009-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.

$PSVersionTable.OS
Microsoft Windows 10.0.18363

$PSVersionTable.PSEdition
Core
austoonz commented 4 years ago

@techthoughts2 Does the Service parameter meet your needs?

Get-AWSCmdletName -Service SQS | Select-Object -First 5

CmdletName                     ServiceOperation             ServiceName                       ModuleName
----------                     ----------------             -----------                       ----------
Add-SQSPermission              AddPermission                Amazon Simple Queue Service (SQS) AWS.Tools.SQS
Add-SQSResourceTag             TagQueue                     Amazon Simple Queue Service (SQS) AWS.Tools.SQS
Clear-SQSQueue                 PurgeQueue                   Amazon Simple Queue Service (SQS) AWS.Tools.SQS
Edit-SQSMessageVisibility      ChangeMessageVisibility      Amazon Simple Queue Service (SQS) AWS.Tools.SQS
Edit-SQSMessageVisibilityBatch ChangeMessageVisibilityBatch Amazon Simple Queue Service (SQS) AWS.Tools.SQS
Get-AWSCmdletName -Service S3 | Select-Object -First 5

CmdletName                          ServiceOperation                 ServiceName                        ModuleName
----------                          ----------------                 -----------                        ----------
Add-S3PublicAccessBlock             PutPublicAccessBlock             Amazon Simple Storage Service (S3) AWS.Tools.S3
Copy-S3Object                       CopyObject                       Amazon Simple Storage Service (S3) AWS.Tools.S3
Get-S3ACL                           GetACL                           Amazon Simple Storage Service (S3) AWS.Tools.S3
Get-S3Bucket                        ListBuckets                      Amazon Simple Storage Service (S3) AWS.Tools.S3
Get-S3BucketAccelerateConfiguration GetBucketAccelerateConfiguration Amazon Simple Storage Service (S3) AWS.Tools.S3
matteo-prosperi commented 4 years ago

Hello, thanks for opening this issue. I support @austoonz answer and would suggest to use Get-AWSCmdletName -Service SQS instead.

Get-AWSCmdletName -CmdletName "*s3*" from your example, returns something but, as you can see, it doesn't show S3 cmdlets. I think the reason is that -CmdletName is expected to be a regular expression but *S3* is not a valid regular expression and the .NET regex implementation behaves in an unexpected way.

Alternatively, the following work: Get-AWSCmdletName -CmdletName "S3" -MatchWithRegex or Get-AWSCmdletName -CmdletName ".*S3.*"

techthoughts2 commented 4 years ago

Thanks for the suggestions. This is good to close out based on the suggestions.