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
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user