powershell - Azure 资源管理器 powershell cmdlet 在 azure 门户测试 Pane (自动化帐户)上无法识别

标签 powershell azure azure-automation

在 Windows Azure 门户中,从我的自动化帐户(自动化帐户 > myAutomation > Runbooks > MyRunbook > 编辑 PowerShell 工作流 Runbook > 测试),我尝试使用 Azure 资源管理器库测试 powershell 脚本,以用于迁移目的。 我编写了一小段 powershell 脚本并在测试 Pane 中对其进行了测试。 我遇到错误消息:

The term 'New-AzureRmHDInsightHiveJobDefinition' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

我想直接从 Windows Azure 门户测试它,因为我需要使用“Get-AutomationPSCredential”等函数的一些结果。

PowerShell 脚本示例

workflow Runbook_Test
{
    param(            
        [parameter(Mandatory=$True)]
        [string] $HDInsightAdminCredendialsName
    )

    $hdInsightCredentials = Get-AutomationPSCredential -Name $HDInsightAdminCredendialsName
    InlineScript {
        $creds = $using:hdInsightCredentials
        $clusterName = 'clusterName'            

        $query = 'A QUERY INSIDE'

        $jobDef = New-AzureRmHDInsightHiveJobDefinition -Query $query;
        $hiveJob = Start-AzureRmHDInsightJob -JobDefinition $jobDef -ClusterName $clusterName -HttpCredential $creds 
        Wait-AzureRmHDInsightJob -JobId $hiveJob.JobId -ClusterName $clusterName -HttpCredential $creds 
    }    
}

我对 cmdlet“Start-AzureRmHDInsightJob”和“Wait-AzureRmHDInsightJob”也有同样的问题。就像 azure 门户无法识别 ARM 库一样。

我肯定错过了什么,但是什么? :) 感谢您的帮助。

最佳答案

您需要将这些模块导入您的 Azure 自动化帐户。在这种情况下,您需要 AzureRM​.HDInsight 模块。有关如何导入模块的信息,请参阅此链接:https://learn.microsoft.com/en-us/azure/automation/automation-runbook-gallery#modules-in-powershell-gallery

问题是,默认情况下,您的帐户仅获得部分 Azure Powershell 模块,其余的则必须手动安装。

关于powershell - Azure 资源管理器 powershell cmdlet 在 azure 门户测试 Pane (自动化帐户)上无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40899342/

相关文章:

azure - Azure 自动化帐户中的 Runbook 和变量数量是否有限制?

windows - 检索powershell中日期范围内修改的文件的完整路径和文件权限

arrays - 确保管道始终生成数组而不使用 @()?

powershell - PowerShell 2 CTP3 ISE 的自定义读取主机对话框

powershell - 从 IIS 绑定(bind)中检索主机名值

c# - 在 Azure 服务总线 SendAsync 方法上捕获异常时遇到问题

azure - 没有 "Common Data Service"API 选项 Azure

Azure Multi-Tenancy SAAS/PAAS?

powershell - 如何使用 PowerShell 将模块导入 Azure 自动化帐户?

Azure 自动化/运行手册/身份验证