Aktivera och konfigurera Microsoft Antimalware för virtuella Azure Resource Manager-datorer
Artikel
Du kan aktivera och konfigurera Microsoft Antimalware för virtuella Azure Resource Manager-datorer. Den här artikeln innehåller kodexempel med PowerShell-cmdletar.
Distribuera Microsoft Antimalware på virtuella Azure Resource Manager-datorer
Anteckning
Innan du kör det här kodexemplet måste du avkommentera variablerna och ange lämpliga värden.
PowerShell
# Script to add Microsoft Antimalware extension to Azure Resource Manager VMs# Specify your subscription ID$subscriptionId= " SUBSCRIPTION ID HERE "# specify location, resource group, and VM for the extension$location = " LOCATION HERE "# eg., “Southeast Asia” or “Central US”$resourceGroupName = " RESOURCE GROUP NAME HERE "$vmName = " VM NAME HERE "# Enable Antimalware with default policies$settingString = ‘{"AntimalwareEnabled": true}’;
# Enable Antimalware with custom policies# $settingString = ‘{# "AntimalwareEnabled": true,# "RealtimeProtectionEnabled": true,# "ScheduledScanSettings": {# "isEnabled": true,# "day": 0,# "time": 120,# "scanType": "Quick"# },# "Exclusions": {# "Extensions": ".ext1,.ext2",# "Paths":"",# "Processes":"sampl1e1.exe, sample2.exe"# },# "SignatureUpdates": {# "FileSharesSources": “”,# "FallbackOrder”: “”,# "ScheduleDay": 0,# "UpdateInterval": 0,# },# "CloudProtection": true ## }’;# Login to your Azure Resource Manager Account and select the Subscription to useLogin-AzureRmAccountSelect-AzureRmSubscription -SubscriptionId$subscriptionId# retrieve the most recent version number of the extension$allVersions= (Get-AzureRmVMExtensionImage -Location$location -PublisherName “Microsoft.Azure.Security” -Type “IaaSAntimalware”).Version
$versionString = $allVersions[($allVersions.count)-1].Split(“.”)[0] + “.” + $allVersions[($allVersions.count)-1].Split(“.”)[1]
# set the extension using prepared values# ****—-Use this script till cmdlets address the -SettingsString format issue we observed ****—-Set-AzureRmVMExtension -ResourceGroupName$resourceGroupName -Location$location -VMName$vmName -Name"IaaSAntimalware" -Publisher “Microsoft.Azure.Security” -ExtensionType “IaaSAntimalware” -TypeHandlerVersion$versionString -SettingString$settingString
Lägga till Microsoft Antimalware i Azure Service Fabric-kluster
Azure Service Fabric använder skalningsuppsättningar för virtuella Azure-datorer för att skapa Service Fabric-kluster. För närvarande är mallen för vm-skalningsuppsättningar som används för att skapa Service Fabric-kluster inte aktiverad med tillägget Mot skadlig kod. Därför måste program mot skadlig kod aktiveras separat i skalningsuppsättningarna. När du aktiverar det på skalningsuppsättningar ärver alla noder som skapats under vm-skalningsuppsättningarna och hämtar tillägget automatiskt.
Kodexemplet nedan visar hur du kan aktivera IaaS Antimalware-tillägget med hjälp av AzureRmVmss PowerShell-cmdletar.
Anteckning
Innan du kör det här kodexemplet måste du avkommentera variablerna och ange lämpliga värden.
PowerShell
# Script to add Microsoft Antimalware extension to VM Scale Set(VMSS) and Service Fabric Cluster(in turn it used VMSS)# Login to your Azure Resource Manager Account and select the Subscription to useLogin-AzureRmAccount# Specify your subscription ID$subscriptionId="SUBSCRIPTION ID HERE"Select-AzureRmSubscription -SubscriptionId$subscriptionId# Specify location, resource group, and VM Scaleset for the extension$location = "LOCATION HERE"# eg., “West US or Southeast Asia” or “Central US”$resourceGroupName = "RESOURCE GROUP NAME HERE"$vmScaleSetName = "YOUR VM SCALE SET NAME"# Configuration.JSON configuration file can be customized as per MSDN documentation: https://msdn.microsoft.com/en-us/library/dn771716.aspx$settingString = ‘{"AntimalwareEnabled": true}’;
# Enable Antimalware with custom policies# $settingString = ‘{# "AntimalwareEnabled": true,# "RealtimeProtectionEnabled": true,# "ScheduledScanSettings": {# "isEnabled": true,# "day": 0,# "time": 120,# "scanType": "Quick"# },# "Exclusions": {# "Extensions": ".ext1,.ext2",# "Paths":"",# "Processes":"sampl1e1.exe, sample2.exe"# } ,# "SignatureUpdates": {# "FileSharesSources": “”,# "FallbackOrder”: “”,# "ScheduleDay": 0,# "UpdateInterval": 0,# },# "CloudProtection": true# }’;# retrieve the most recent version number of the extension$allVersions= (Get-AzureRmVMExtensionImage -Location$location -PublisherName “Microsoft.Azure.Security” -Type “IaaSAntimalware”).Version
$versionString = $allVersions[($allVersions.count)-1].Split(“.”)[0] + “.” + $allVersions[($allVersions.count)-1].Split(“.”)[1]
$VMSS = Get-AzureRmVmss -ResourceGroupName$resourceGroupName -VMScaleSetName$vmScaleSetNameAdd-AzureRmVmssExtension -VirtualMachineScaleSet$VMSS -Name “IaaSAntimalware” -Publisher “Microsoft.Azure.Security” -Type “IaaSAntimalware” -TypeHandlerVersion$versionStringUpdate-AzureRmVmss -ResourceGroupName$resourceGroupName -Name$vmScaleSetName -VirtualMachineScaleSet$VMSS
Lägga till Microsoft Antimalware i Azure Cloud Service med utökad support
Kodexemplet nedan visar hur du kan lägga till eller konfigurera Microsoft Antimalware till Azure Cloud Service med utökad support (CS-ES) via PowerShell-cmdletar.
Anteckning
Innan du kör det här kodexemplet måste du avkommentera variablerna och ange lämpliga värden.
PowerShell
# Create Antimalware extension object, where file is the AntimalwareSettings$xmlconfig = [IO.File]::ReadAllText("C:\path\to\file.xml")
$extension = New-AzCloudServiceExtensionObject -Name"AntimalwareExtension" -Type"PaaSAntimalware" -Publisher"Microsoft.Azure.Security" -Setting$xmlconfig -TypeHandlerVersion"1.5" -AutoUpgradeMinorVersion$true# Get existing Cloud Service$cloudService = Get-AzCloudService -ResourceGroup"ContosOrg" -CloudServiceName"ContosoCS"# Add Antimalware extension to existing Cloud Service extension object$cloudService.ExtensionProfile.Extension = $cloudService.ExtensionProfile.Extension + $extension# Update Cloud Service$cloudService | Update-AzCloudService
Här är ett exempel på XML-filen för privat konfiguration
Lägga till Microsoft Antimalware för Azure Arc-aktiverade servrar
Kodexemplet nedan visar hur du kan lägga till Microsoft Antimalware för Azure Arc-aktiverade servrar via PowerShell-cmdletar.
Anteckning
Innan du kör det här kodexemplet måste du avkommentera variablerna och ange lämpliga värden.
PowerShell
#Before using Azure PowerShell to manage VM extensions on your hybrid server managed by Azure Arc-enabled servers, you need to install the Az.ConnectedMachine module. Run the following command on your Azure Arc-enabled server:#If you have Az.ConnectedMachine installed, please make sure the version is at least 0.4.0install-module -Name Az.ConnectedMachine
Import-Module -name Az.ConnectedMachine
# specify location, resource group, and VM for the extension$subscriptionid =" SUBSCRIPTION ID HERE "$location = " LOCATION HERE "# eg., “Southeast Asia” or “Central US”$resourceGroupName = " RESOURCE GROUP NAME HERE "$machineName = "MACHINE NAME HERE "# Enable Antimalware with default policies$setting = @{"AntimalwareEnabled"=$true}
# Enable Antimalware with custom policies$setting2 = @{
"AntimalwareEnabled"=$true;
"RealtimeProtectionEnabled"=$true;
"ScheduledScanSettings"= @{
"isEnabled"=$true;
"day"=0;
"time"=120;
"scanType"="Quick"
};
"Exclusions"= @{
"Extensions"=".ext1, .ext2";
"Paths"="";
"Processes"="sampl1e1.exe, sample2.exe"
};
"SignatureUpdates"= @{
"FileSharesSources"=“”;
"FallbackOrder”=“”;
"ScheduleDay"=0;
"UpdateInterval"=0;
};
"CloudProtection"=$true
}
# Will be prompted to login
Connect-AzAccount
# Enable Antimalware with the policies
New-AzConnectedMachineExtension -Name "IaaSAntimalware" -ResourceGroupName $resourceGroupName -MachineName $machineName -Location $location -SubscriptionId $subscriptionid -Publisher “Microsoft.Azure.Security” -Settings $setting -ExtensionType “IaaSAntimalware”
I slutet av den här modulen kommer du att förstå hur Microsoft Defender för molnet för Azure Arc-aktiverade servrar kan hjälpa dig att skydda dina molnbaserade program mot olika cyberhot.
Planera och köra en distributionsstrategi för slutpunkter med hjälp av viktiga delar av modern hantering, samhanteringsmetoder och Microsoft Intune-integrering.