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

Set-AzureVMMicrosoftAntimalwareExtension

为虚拟机配置Microsoft反恶意软件扩展。

注意

本文档中引用的 cmdlet 用于管理使用 Azure Service Manager (ASM) API 的旧 Azure 资源。 创建新的资源时,不建议使用此旧版 PowerShell 模块,因为 ASM 计划停用。 有关详细信息,请参阅 Azure Service Manager 停用

Az PowerShell 模块是推荐的 PowerShell 模块,用于使用 PowerShell 管理 Azure 资源管理器 (ARM) 资源。

语法

Set-AzureVMMicrosoftAntimalwareExtension
   [-AntimalwareConfigFile] <String>
   [[-Version] <String>]
   [[-Monitoring] <String>]
   [[-StorageContext] <AzureStorageContext>]
   -VM <IPersistentVM>
   [-Profile <AzureSMProfile>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]
Set-AzureVMMicrosoftAntimalwareExtension
   [-AntimalwareConfiguration] <String>
   [[-Version] <String>]
   [[-Monitoring] <String>]
   [[-StorageContext] <AzureStorageContext>]
   -VM <IPersistentVM>
   [-Profile <AzureSMProfile>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]
Set-AzureVMMicrosoftAntimalwareExtension
   [[-Version] <String>]
   [-Disable]
   -VM <IPersistentVM>
   [-Profile <AzureSMProfile>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]
Set-AzureVMMicrosoftAntimalwareExtension
   [-Uninstall]
   -VM <IPersistentVM>
   [-Profile <AzureSMProfile>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]
Set-AzureVMMicrosoftAntimalwareExtension
   [-Monitoring] <String>
   [[-StorageContext] <AzureStorageContext>]
   [-NoConfig]
   -VM <IPersistentVM>
   [-Profile <AzureSMProfile>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]

说明

Set-AzureVMMicrosoftAntimalwareExtension cmdlet 为虚拟机配置Microsoft反恶意软件扩展。 可以启用、禁用或卸载扩展。

示例

示例 1:使用配置文件启用扩展

PS C:\> Get-AzureVM -ServiceName "ContosoService03" -Name "ContosoVM22" | Set-AzureVMMicrosoftAntimalwareExtension -AntimalwareConfigFile 'C:\configuration\contosoVM.json' | Update-AzureVM

此命令使用配置文件启用Microsoft反恶意软件扩展。 该命令使用 Get-AzureVM cmdlet 获取指定的虚拟机对象,然后使用管道运算符将该对象传递给当前 cmdlet。

示例 2:启用扩展并启用监视

PS C:\> $StorageContext = New-AzureStorageContext -StorageAccountName "contosostoragemain" -StorageAccountKey (Get-AzureStorageKey -StorageAccountName "Contosostoragemain").PrimaryP
S C:\> Get-AzureVM -ServiceName "ContosoService03" -Name"ContosoVM22" | Set-AzureVMMicrosoftAntimalwareExtension -AntimalwareConfigFile 'C:\configuration\contosoVM.json" -Monitoring ON -StorageContext $StorageContext | Update-AzureVM

第一个命令使用 New-AzureStorageContext cmdlet 创建 AzureStorageContext 对象,然后将其存储在$StorageContext变量中。

示例 3:通过指定配置对象启用扩展

PS C:\> $Config_String = [IO.File]::ReadAllText('C:\configuration\contosoVM.json')
PS C:\> Get-AzureVM -ServiceName "ContosoService03" -Name "ContosoVM22" | Set-AzureVMMicrosoftAntimalwareExtension -AntimalwareConfiguration $Config_String | Update-AzureVM

第一个命令通过读取 Microsoft 反恶意软件扩展的 JSON 配置并将其存储在 $config_string 变量中来创建字符串对象。

示例 4:禁用扩展

PS C:\> Get-AzureVM -ServiceName "ContosoService03" -Name "ContosoVM22" | Set-AzureVMMicrosoftAntimalwareExtension -Disable | Update-AzureVM

此命令禁用扩展,而不将其删除。 该命令使用 Get-AzureVM 获取指定的虚拟机对象,然后将该对象传递给当前 cmdlet。

示例 5:删除扩展

PS C:\> Get-AzureVM -ServiceName "ContosoService03" -Name"ContosoVM22" | Set-AzureVMMicrosoftAntimalwareExtension -Uninstall | Update-AzureVM

此命令从虚拟机中删除Microsoft反恶意软件扩展。 该命令使用 Get-AzureVM 获取指定的虚拟机对象,然后将该对象传递给当前 cmdlet。

参数

-AntimalwareConfigFile

指定Microsoft反恶意软件配置文件的绝对路径。 如果指定反恶意软件配置参数,请不要指定此参数。 配置文件必须至少包括以下内容才能启用Microsoft反恶意软件扩展:

{ "AntimalwareEnabled": true }

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

-AntimalwareConfiguration

指定包含Microsoft反恶意软件配置的字符串对象。 此对象不得$Null或为空。 如果指定 AntimalwareConfigFile 参数,请不要指定此参数。 配置对象必须至少包括以下内容才能启用Microsoft反恶意软件扩展:****{ “AntimalwareEnabled”: true }

Microsoft Antimalware JSON 配置示例:

{ “AntimalwareEnabled”: true, “RealtimeProtectionEnabled”: true, “ScheduledScanSettings”: { “isEnabled”: true, “day”: 1, “time”: 120, “scanType”: “Full” },

“Exclusions”: { “Extensions”: “.ext1;.ext2“、”Path“: ”c:\excluded-path-1;c:\excluded-path-2“, ”Process“: ”excludedproc1.exe;excludedproc2.exe“ }

}

注意:反恶意软件Enabled 是必需参数。 值:true= 启用。 false= 错误出为 false 不是受支持的值

RealtimeProtectionEnabled:true/false。 true = 启用。 false = 禁用。 默认值为 true

ScheduledScanSettings:
isEnabled=true/false day=0-8 (0-daily, 1-Sunday, 2-Monday, ...., 7-Saturday, 8-Disabled) time=0-1440 (以午夜后的分钟为单位 - 60-1AM>, 120 -> 2AM, ... ) scanType=“Quick” 或 “Full” (默认值为快速)注意:如果 isEnabled=true 是唯一提供的设置,则设置以下默认值:day=7(星期六),time=120 (2 AM),scanType=“Quick” 排除项: 同一列表中的多个排除项是使用分号分隔符指定的。

如果未指定排除项,则系统上的现有排除项(如果有)将被空白覆盖。

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

-Disable

指示 cmdlet 禁用Microsoft反恶意软件扩展。 若要在同一虚拟机上重新启用扩展,请在不使用 Disable 参数的情况下运行 Set-AzureVMMicrosoftAntimalwareExtension。

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

-InformationAction

指定此 cmdlet 如何响应信息事件。

此参数的可接受值为:

  • 继续
  • 忽略
  • 询问
  • SilentlyContinue
  • 停止
  • Suspend
类型:ActionPreference
别名:infa
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-InformationVariable

指定信息变量。

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

-Monitoring

指定是否收集Microsoft反恶意软件事件。

此参数的可接受值为:

  • 上。 将Microsoft反恶意软件事件收集到存储上下文。
  • 关闭。 不要收集Microsoft反恶意软件事件。
类型:String
Position:3
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-NoConfig

指示此 cmdlet 指定 NoConfig 选项。

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

-Profile

指定此 cmdlet 从中读取的 Azure 配置文件。 如果未指定配置文件,此 cmdlet 将从本地默认配置文件中读取。

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

-StorageContext

指定用于Microsoft反恶意软件监视的 Azure 存储上下文。

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

-Uninstall

指示此 cmdlet 从虚拟机卸载 Microsoft 反恶意软件扩展。 如果启用了监视,该 cmdlet 还会删除Microsoft反恶意软件事件的集合。

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

-Version

将扩展版本指定为字符串。 注意:支持的版本为 1.5。 Microsoft不支持旧版本。

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

-VM

将虚拟机指定为 IPersistentVM 对象。

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