你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Set-AzDeviceSecurityGroup

创建或更新设备安全组

语法

Set-AzDeviceSecurityGroup
   -Name <String>
   -HubResourceId <String>
   [-ThresholdRule <PSThresholdCustomAlertRule[]>]
   [-TimeWindowRule <PSTimeWindowCustomAlertRule[]>]
   [-AllowlistRule <PSAllowlistCustomAlertRule[]>]
   [-DenylistRule <PSDenylistCustomAlertRule[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzDeviceSecurityGroup
   [-ThresholdRule <PSThresholdCustomAlertRule[]>]
   [-TimeWindowRule <PSTimeWindowCustomAlertRule[]>]
   [-AllowlistRule <PSAllowlistCustomAlertRule[]>]
   [-DenylistRule <PSDenylistCustomAlertRule[]>]
   -InputObject <PSDeviceSecurityGroup>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzDeviceSecurityGroup
   [-ThresholdRule <PSThresholdCustomAlertRule[]>]
   [-TimeWindowRule <PSTimeWindowCustomAlertRule[]>]
   [-AllowlistRule <PSAllowlistCustomAlertRule[]>]
   [-DenylistRule <PSDenylistCustomAlertRule[]>]
   -ResourceId <String>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

说明

Set-AzDeviceSecurityGroup cmdlet 创建或更新 iot 安全解决方案中定义的设备安全组。

示例

示例 1

$TimeWindowSize = New-TimeSpan -Minutes 5
$TimeWindowRule = New-AzDeviceSecurityGroupTimeWindowRuleObject -Type "ActiveConnectionsNotInAllowedRange" -Enabled $true `
-MaxThreshold 30 -MinThreshold 0 -TimeWindowSize $TimeWindowSize
Set-AzDeviceSecurityGroup -Name "MySecurityGroup" `
-HubResourceId "/subscriptions/XXXXXXXX-XXXX-XXXXX-XXXX-XXXXXXXXXXXX/resourceGroups/MyResourceGroup/providers/Microsoft.Devices/IotHubs/MyHub" `
-TimeWindowRule $TimeWindowRules

Id: "/subscriptions/XXXXXXXX-XXXX-XXXXX-XXXX-XXXXXXXXXXXX/resourceGroups/MyResourceGroup/providers/Microsoft.Devices/IotHubs/MyHub/providers/Microsoft.Security/deviceSecurityGroups/MySecurityGroup"
Name: "MySecurityGroup"
Type: "Microsoft.Security/deviceSecurityGroups"
ThresholdRules: []
TimeWindowRules: [
			{
              RuleType: "ActiveConnectionsNotInAllowedRange"
              DisplayName: "Number of active connections is not in allowed range"
              Description: "Get an alert when the number of active connections of a device in the time window is not in the allowed range"
              IsEnabled: true
              MinThreshold: 0
              MaxThreshold: 0
              TimeWindowSize: "PT5M"
            }]
AllowlistRules: [
			{
              RuleType": "ConnectionToIpNotAllowed",
              DisplayName: "Outbound connection to an ip that isn't allowed"
              Description: "Get an alert when an outbound connection is created between your device and an ip that isn't allowed"
              IsEnabled: false
              ValueType: "IpCidr"
              AllowlistValues: []
            },
            {
              RuleType: "LocalUserNotAllowed"
              DisplayName: "Login by a local user that isn't allowed"
              Description: "Get an alert when a local user that isn't allowed logins to the device"
              IsEnabled: false
              ValueType: "String"
              AllowlistValues: []
            }]
DenylistRules: []

使用规则类型“ActiveConnectionsNotInAllowedRange”从IoT 中心“/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/MyResourceGroup/providers/Microsoft.Devices/IotHubs/MyHub”更新现有设备安全组

参数

-AllowlistRule

允许列表规则。

类型:PSAllowlistCustomAlertRule[]
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Confirm

提示你在运行 cmdlet 之前进行确认。

类型:SwitchParameter
别名:cf
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

类型:IAzureContextContainer
别名:AzContext, AzureRmContext, AzureCredential
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-DenylistRule

拒绝列表规则。

类型:PSDenylistCustomAlertRule[]
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-HubResourceId

IoT 中心资源 ID。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-InputObject

输入对象。

类型:PSDeviceSecurityGroup
Position:Named
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-Name

资源名称。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-ResourceId

要调用其上的命令的安全资源的 ID。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-ThresholdRule

阈值规则。

类型:PSThresholdCustomAlertRule[]
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-TimeWindowRule

时间窗口规则。

类型:PSTimeWindowCustomAlertRule[]
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-WhatIf

显示运行该 cmdlet 时会发生什么情况。 cmdlet 未运行。

类型:SwitchParameter
别名:wi
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

输入

PSThresholdCustomAlertRule[]

PSTimeWindowCustomAlertRule[]

PSAllowlistCustomAlertRule[]

PSDenylistCustomAlertRule[]

PSDeviceSecurityGroup

String

输出

PSDeviceSecurityGroup