Ejemplo n.º 1
0
        public override void ExecuteCmdlet()
        {
            switch (ParameterSetName)
            {
            case ParameterSetNames.SolutionLevelResource:
                break;

            case ParameterSetNames.ResourceId:
                ResourceGroupName = AzureIdUtilities.GetResourceGroup(ResourceId);
                SolutionName      = AzureIdUtilities.GetIotSolutionResourceName(ResourceId);
                var idParts = ResourceId.Split('/');
                if (idParts.Length > 2)
                {
                    Name = $"{idParts[idParts.Length - 2]}/{idParts[idParts.Length - 1]}";
                }
                else
                {
                    throw new ArgumentException("Invalid format of the resource identifier.", "ResourceId");
                }
                break;

            case ParameterSetNames.InputObject:
                ResourceGroupName = AzureIdUtilities.GetResourceGroup(InputObject.Id);
                SolutionName      = AzureIdUtilities.GetIotSolutionResourceName(InputObject.Id);
                Name = AzureIdUtilities.GetResourceName(InputObject.Name);
                break;

            default:
                throw new PSInvalidOperationException();
            }

            if (ShouldProcess(Name, VerbsCommon.Set))
            {
                SecurityCenterClient.IotSecuritySolutionsAnalyticsAggregatedAlert.DismissWithHttpMessagesAsync(ResourceGroupName, SolutionName, Name).GetAwaiter().GetResult();
            }

            if (PassThru.IsPresent)
            {
                WriteObject(true);
            }
        }