##[错误]术语“New-AzActionGroupReceiver”未被识别为 cmdlet、函数、脚本文件或可操作程序的名称

问题描述 投票:0回答:1

我正在运行一个 powershell 脚本,它抛出了错误

##[error]The term 'New-AzActionGroupReceiver' is not recognized as the name of a cmdlet, function, script file, or operable program.

由于它属于模块 Az.Monitor,我尝试在命令之前安装它

"New-AzActionGroupReceiver -Name $name -EmailReceiver -EmailAddress $item"
被执行。我使用

安装了该模块

Install-Module -Name Az.Monitor -Force

错误还是一样

我在 azure devops 管道上运行脚本,尽管我尝试安装模块并部署,但失败了

azure powershell
1个回答
0
投票

由于版本问题,无法识别“New-AzActionGroupReceiver”作为 cmdlet、函数、脚本文件或可操作程序的名称。

错误消息“The term 'New-AzActionGroupReceiver' is not recognize”表示 PowerShell 无法识别该命令,可能是因为相应的模块未安装或正确加载,或者安装的 powershell 版本不同。

由于您按照重新安装模块的步骤操作,这也可能是由于 PowerShell 提供程序的版本所致。

按照下面提到的命令来解决您提到的问题。

  • 检查您正在使用的版本 $PSVersionTable.PSVersion enter image description here

  • 确保您正确安装了模块。您可以通过运行以下命令来验证这一点

    Get-InstalledModule -Name Az.Monitor

    如果模块未列出,请尝试重新安装

    Install-Module -Name Az.Monitor -Force

  • 安装模块后,请确保将其导入到 PowerShell 会话中。使用以下命令

    Import-Module -Name Az.Monitor

    要验证该命令是否可识别,请按照以下命令操作

    Get-Command -Name New-AzActionGroupReceiver

enter image description here

  • 现在按照以下命令来配置您正在寻找的需求

    导入模块Az.Monitor $name =“维奈·库马尔” $item = "你的邮件ID" New-AzActionGroupReceiver -Name $name -EmailReceiver -EmailAddress $item

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.