diff --git a/src/Security/Security/Cmdlets/Alerts/SetAlerts.cs b/src/Security/Security/Cmdlets/Alerts/SetAlerts.cs index c948d40378fc..630d679f6501 100644 --- a/src/Security/Security/Cmdlets/Alerts/SetAlerts.cs +++ b/src/Security/Security/Cmdlets/Alerts/SetAlerts.cs @@ -57,6 +57,10 @@ public class SetAlerts : SecurityCenterCmdletBase [ValidateNotNullOrEmpty] public PSSecurityAlert InputObject { get; set; } + [Parameter(ParameterSetName = ParameterSetNames.InputObjectV3, Mandatory = true, ValueFromPipeline = true, HelpMessage = ParameterHelpMessages.InputObjectV3)] + [ValidateNotNullOrEmpty] + public PSSecurityAlertV3 InputObjectV3 { get; set; } + [Parameter(Mandatory = false, HelpMessage = ParameterHelpMessages.PassThru)] public SwitchParameter PassThru { get; set; } @@ -66,6 +70,7 @@ public override void ExecuteCmdlet() var name = Name; var actionType = ActionType; var location = Location; + var status = ""; switch (ParameterSetName) { @@ -77,29 +82,39 @@ public override void ExecuteCmdlet() name = AzureIdUtilities.GetResourceName(ResourceId); break; case ParameterSetNames.InputObject: - switch (InputObject.State.ToLower()) - { - case "dismissed": - actionType = "Dismiss"; - break; - case "active": - actionType = "Activate"; - break; - case "resolved": - actionType = "Resolve"; - break; - default: - break; - } - + status = InputObject.State; name = InputObject.Name; rg = AzureIdUtilities.GetResourceGroup(InputObject.Id); location = AzureIdUtilities.GetResourceLocation(InputObject.Id); break; + case ParameterSetNames.InputObjectV3: + status = InputObjectV3.Status; + name = InputObjectV3.Name; + rg = AzureIdUtilities.GetResourceGroup(InputObjectV3.Id); + location = AzureIdUtilities.GetResourceLocation(InputObjectV3.Id); + break; default: throw new PSInvalidOperationException(); } + if (!string.IsNullOrEmpty(status)) + { + switch (status.ToLower()) + { + case "dismissed": + actionType = "Dismiss"; + break; + case "active": + actionType = "Activate"; + break; + case "resolved": + actionType = "Resolve"; + break; + default: + break; + } + } + SecurityCenterClient.AscLocation = location; if (string.IsNullOrEmpty(rg)) diff --git a/src/Security/Security/Common/ParameterHelpMessages.cs b/src/Security/Security/Common/ParameterHelpMessages.cs index e140b1bdd24d..69d9a02b5ec2 100644 --- a/src/Security/Security/Common/ParameterHelpMessages.cs +++ b/src/Security/Security/Common/ParameterHelpMessages.cs @@ -26,6 +26,7 @@ public static class ParameterHelpMessages public const string Scope = "Scope."; public const string Kind = "Kind."; public const string InputObject = "Input Object."; + public const string InputObjectV3 = "Input Object V3."; public const string Location = "Location."; public const string PassThru = "Return whether the operation was successful."; public const string Tags = "Tags."; diff --git a/src/Security/Security/Common/ParameterSetNames.cs b/src/Security/Security/Common/ParameterSetNames.cs index 5c42234ab88d..aef803308b18 100644 --- a/src/Security/Security/Common/ParameterSetNames.cs +++ b/src/Security/Security/Common/ParameterSetNames.cs @@ -28,6 +28,7 @@ public static class ParameterSetNames public const string ResourceIdLevelResource = "ResourceIdLevelResource"; public const string ResourceId = "ResourceId"; public const string InputObject = "InputObject"; + public const string InputObjectV3 = "InputObjectV3"; public const string PolicyOn = "PolicyOn"; public const string PolicyOff = "PolicyOff";