Move "Run-Antivirus" step outside of image-generation (#574)
* Move "Run-Antivirus" step outside of image-generation Co-authored-by: Dibir Magomedsaygitov <[email protected]>
This commit is contained in:
co-authored by
Dibir Magomedsaygitov
parent
0c0f68b26c
commit
9b3924a23d
@@ -15,6 +15,7 @@
|
|||||||
"virtual_network_subnet_name": "{{env `VNET_SUBNET`}}",
|
"virtual_network_subnet_name": "{{env `VNET_SUBNET`}}",
|
||||||
"private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}",
|
"private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}",
|
||||||
"vm_size": "Standard_DS4_v2",
|
"vm_size": "Standard_DS4_v2",
|
||||||
|
"run_scan_antivirus": "false",
|
||||||
|
|
||||||
"root_folder": "C:",
|
"root_folder": "C:",
|
||||||
"image_folder": "C:\\image",
|
"image_folder": "C:\\image",
|
||||||
@@ -876,8 +877,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "powershell",
|
"type": "powershell",
|
||||||
|
"environment_vars":[
|
||||||
|
"RUN_SCAN_ANTIVIRUS={{user `run_scan_antivirus`}}"
|
||||||
|
],
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{ template_dir }}/scripts/Installers/Windows2016/Run-Antivirus.ps1"
|
"{{ template_dir }}/scripts/Installers/Run-Antivirus.ps1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "powershell",
|
||||||
|
"scripts":[
|
||||||
|
"{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"virtual_network_subnet_name": "{{env `VNET_SUBNET`}}",
|
"virtual_network_subnet_name": "{{env `VNET_SUBNET`}}",
|
||||||
"private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}",
|
"private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}",
|
||||||
"vm_size": "Standard_DS4_v2",
|
"vm_size": "Standard_DS4_v2",
|
||||||
|
"run_scan_antivirus": "false",
|
||||||
|
|
||||||
"root_folder": "C:",
|
"root_folder": "C:",
|
||||||
"image_folder": "C:\\image",
|
"image_folder": "C:\\image",
|
||||||
@@ -869,8 +870,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "powershell",
|
"type": "powershell",
|
||||||
|
"environment_vars":[
|
||||||
|
"RUN_SCAN_ANTIVIRUS={{user `run_scan_antivirus`}}"
|
||||||
|
],
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{ template_dir }}/scripts/Installers/Windows2019/Run-Antivirus.ps1"
|
"{{ template_dir }}/scripts/Installers/Run-Antivirus.ps1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "powershell",
|
||||||
|
"scripts":[
|
||||||
|
"{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Write-Host "Set antivirus parameters"
|
||||||
|
Set-MpPreference -ScanAvgCPULoadFactor 5 -ExclusionPath "D:\", "C:\"
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
################################################################################
|
||||||
|
## File: Run-Antivirus.ps1
|
||||||
|
## Desc: Run a full antivirus scan.
|
||||||
|
## Run right after cleanup before we sysprep
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
if ($env:run_scan_antivirus -eq $true) {
|
||||||
|
try {
|
||||||
|
Update-MpSignature
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "Some error was found"
|
||||||
|
Write-Host $_
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Make sure windefend is going to start"
|
||||||
|
Start-Service windefend -ErrorAction Continue
|
||||||
|
Write-Host "Waiting for windefend to report as running"
|
||||||
|
$service = Get-Service "Windefend"
|
||||||
|
$service.WaitForStatus("Running","00:10:00")
|
||||||
|
|
||||||
|
Write-Host "Run antivirus"
|
||||||
|
# Tell Defender to use 100% of the CPU during the scan
|
||||||
|
Set-MpPreference -ScanAvgCPULoadFactor 100
|
||||||
|
# Full Scan
|
||||||
|
Start-Process -FilePath "C:\Program Files\Windows Defender\MpCmdRun.exe" -ArgumentList ("-Scan","-ScanType", 2) -Wait
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Scanning process has been skipped"
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
## File: Run-Antivirus.ps1
|
|
||||||
## Desc: Run a full antivirus scan.
|
|
||||||
## Run right after cleanup before we sysprep
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
Write-Host "Run antivirus"
|
|
||||||
Push-Location "C:\Program Files\Windows Defender"
|
|
||||||
|
|
||||||
# Tell Defender to use 100% of the CPU during the scan
|
|
||||||
Set-MpPreference -ScanAvgCPULoadFactor 100
|
|
||||||
|
|
||||||
# Full Scan
|
|
||||||
.\MpCmdRun.exe -Scan -ScanType 2
|
|
||||||
Pop-Location
|
|
||||||
|
|
||||||
Write-Host "Set antivirus parmeters"
|
|
||||||
Set-MpPreference -ScanAvgCPULoadFactor 5 `
|
|
||||||
-ExclusionPath "D:\", "C:\"
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
## File: Run-Antivirus.ps1
|
|
||||||
## Desc: Run a full antivirus scan.
|
|
||||||
## Run right after cleanup before we sysprep
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
Write-Host "Make sure windefend is going to start"
|
|
||||||
Start-Service windefend -ErrorAction Continue
|
|
||||||
|
|
||||||
Write-Host "Waiting for windefend to report as running"
|
|
||||||
$service = Get-Service "Windefend"
|
|
||||||
$service.WaitForStatus("Running","00:10:00")
|
|
||||||
|
|
||||||
Write-Host "Run antivirus"
|
|
||||||
Push-Location "C:\Program Files\Windows Defender"
|
|
||||||
|
|
||||||
# Tell Defender to use 100% of the CPU during the scan
|
|
||||||
Set-MpPreference -ScanAvgCPULoadFactor 100
|
|
||||||
|
|
||||||
# Full Scan
|
|
||||||
.\MpCmdRun.exe -Scan -ScanType 2
|
|
||||||
Pop-Location
|
|
||||||
|
|
||||||
Update-MpSignature
|
|
||||||
Write-Host "Set antivirus parmeters"
|
|
||||||
Set-MpPreference -ScanAvgCPULoadFactor 5 `
|
|
||||||
-ExclusionPath "D:\", "C:\"
|
|
||||||
Reference in New Issue
Block a user