【问题标题】:Unable to find type [Microsoft.Azure.PowerShell.Cmdlets.SecurityInsights.Models.Api20210901Preview.AutomationRuleRunPlaybookAction]无法找到类型 [Microsoft.Azure.PowerShell.Cmdlets.SecurityInsights.Models.Api20210901Preview.AutomationRuleRunPlaybookAction]
【发布时间】:2023-01-23 02:18:10
【问题描述】:

我正在尝试使用 Powershell runbook 中的以下命令在 Sentinel 中创建自动化规则。我已经在Runbook中导入了5.1版本的SecurityInsights模块。相同的命令在 VScode Powershell 中运行良好。但我只在运行手册中遇到这个问题。

$LogicAppResourceId = Get-AzLogicApp -ResourceGroupName "myResourceGroup" -Name "Reset-AADPassword"
 $automationRuleAction = [Microsoft.Azure.PowerShell.Cmdlets.SecurityInsights.Models.Api20210901Preview.AutomationRuleRunPlaybookAction]::new()
 $automationRuleAction.Order = 1
 $automationRuleAction.ActionType = "RunPlaybook"
 $automationRuleAction.ActionConfigurationLogicAppResourceId = ($LogicAppResourceId.Id)
 $automationRuleAction.ActionConfigurationTenantId = (Get-AzContext).Tenant.Id
 New-AzSentinelAutomationRule -ResourceGroupName "myResourceGroup" -WorkspaceName "myWorkspaceName" -Id ((New-Guid).Guid) -Action $automationRuleAction -DisplayName "Run Playbook to reset AAD password" -Order 2 -TriggeringLogicIsEnabled

我面临以下错误:

System.Management.Automation.RuntimeException: Unable to find type [Microsoft.Azure.PowerShell.Cmdlets.SecurityInsights.Models.Api20210901Preview.AutomationRuleRunPlaybookAction].
   at System.Management.Automation.TypeOps.ResolveTypeName(ITypeName typeName, IScriptExtent errorPos)
   at System.Management.Automation.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
System.Management.Automation.RuntimeException: The property 'Order' cannot be found on this object. Verify that the property exists and can be set.
   at CallSite.Target(Closure , CallSite , Object , Int32 )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
System.Management.Automation.RuntimeException: The property 'ActionType' cannot be found on this object. Verify that the property exists and can be set.
   at CallSite.Target(Closure , CallSite , Object , String )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
System.Management.Automation.RuntimeException: The property 'ActionConfigurationLogicAppResourceId' cannot be found on this object. Verify that the property exists and can be set.

【问题讨论】:

    标签: powershell azure-runbook azure-sentinel


    【解决方案1】:

    我已经在我的环境中复制并得到如下预期结果:

    我已经尝试了你的命令并得到了与你最初得到的相同的错误:

    然后我通过以下过程从本地计算机导入Az.SecurityInsights

    首先,从here 下载文件:

    然后我已经导入到运行手册中,如下所示:

    导入和下载到 Azure 门户需要一些时间:

    (虽然导入了 3 个版本,但不知道哪个有效,等了大约 30 分钟才回来)

    然后我在代码的开头将以下命令添加到我的脚本中,然后是其余代码:

    Import-Module Az.SecurityInsights
    

    现在当我测试它并且它完成时没有错误如下

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-31
    • 1970-01-01
    相关资源
    最近更新 更多