How to fix cmdlets is not recognized (New-AzScheduledQueryRuleAznsAction,New-AzScheduledQueryRuleSchedule, , New-AzScheduledQueryRuleLogMetricTrigger, Group, New-AzScheduledQueryRuleSource, New-AzScheduledQueryRuleTriggerCondition, etc...)

Menta, SivaKumar 15 Reputation points
2023-07-10T13:55:39.7+00:00

Hi All,

I'm trying to create Azure alert rule by running PowerShell script in Azure PowerShell and getting below error (

* is not recognized as a name of a cmdlet, function, script file, or executable
     | program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

related to each of following cmdlets

   New-AzScheduledQueryRuleAlertingAction
   New-AzScheduledQueryRule
   New-AzScheduledQueryRuleTriggerCondition
   New-AzScheduledQueryRuleSource
   New-AzScheduledQueryRuleSchedule
   New-AzScheduledQueryRuleLogMetricTrigger
   New-AzScheduledQueryRuleAznsActionGroup

When tried to create object reference for one of cmdlets getting below error. As I'm new to PowerShell and have limited time to explore, could you please guide me with steps to resolve above errors.

User's image

Let me know for any additional details.

Thanks & Regards,

Siva Kumar

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
1,867 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Menta, SivaKumar 15 Reputation points
    2023-07-12T15:41:07.76+00:00

    I couldn't resolve cmdlets related errors for below cmdlets:

    New-AzScheduledQueryRuleAznsActionGroup

    New-AzScheduledQueryRuleLogMetricTrigger

    New-AzScheduledQueryRuleSchedule

    New-AzScheduledQueryRuleSource

    New-AzScheduledQueryRuleTriggerCondition

    New-AzScheduledQueryRuleAlertingAction

    So, I started creating alert rule based on documentation ( Link)

    Successfully executed example reference alert rule creation query (Link).

    Considering as a reference trying to create alert rule for Machine learning workspace pipeline failure but getting error "New-AzScheduledQueryRuleConditionObject: Cannot process argument transformation on parameter 'Query'. Cannot convert value to type System.String."

    User's image

    Any suggestions.

    1 person found this answer helpful.

  2. dashanan13 845 Reputation points
    2023-07-10T21:07:34.0266667+00:00

    Hei @Anonymous

    Thank you for contacting Microsoft Community.

    As i gather, you have a cmdlet that can not be found.

    There are a couple of ways around it,

    1. Make sure you have AZ module for powershell is installed explained here
    2. Make sure you got AZ module installed before running a script that uses its cmdlets, guide is here
    3. Use command references to check if they exist, Azure powershell command reference is here. This web page gives you a list of command lines functions of left and when one of them is selected the documentation appears on the right side.
    4. Use tab completion, this feature enables you to write a part of the cmdlet, followed by a tab key stroke to complete the name of the cmdlet and also to get a list of valid arguments. This makes it difficult to make typos. Note: This can also be used to check if the commands mentioned in a copied script are correct. If the cmdlet does not tab complete, it will not work as powershell does not know about it.
    5. Use Microsoft learn articles to find a solution to the problems and use the code provided there, example this article shows how to "Create or edit an alert rule" with Azure powershell, portal and cli.

    Please mark this as "Answer", if it helped.