Start::
CloseProcesses:
SystemRestore: On
CreateRestorePoint:
cmd: DISM.exe /Online /Cleanup-image /Restorehealth
cmd: sfc /scannow
cmd: winmgmt /salvagerepository
cmd: winmgmt /verifyrepository
StartBatch:
WMIC SERVICE WHERE Name="dcomlaunch" set startmode="auto"
WMIC SERVICE WHERE Name="nsi" set startmode="auto"
WMIC SERVICE WHERE Name="dhcp" set startmode="auto"
WMIC SERVICE WHERE Name="rpcss" set startmode="auto"
WMIC SERVICE WHERE Name="rpceptmapper" set startmode="auto"
WMIC SERVICE WHERE Name="winmgmt" set startmode="auto"
WMIC SERVICE WHERE Name="sdrsvc" set startmode="manual"
WMIC SERVICE WHERE Name="vss" set startmode="manual"
WMIC SERVICE WHERE Name="eventlog" set startmode="auto"
WMIC SERVICE WHERE Name="bfe" set startmode="auto"
WMIC SERVICE WHERE Name="eventsystem" set startmode="auto"
WMIC SERVICE WHERE Name="msiserver" set startmode="manual"
WMIC SERVICE WHERE Name="sstpsvc" set startmode="manual"
WMIC SERVICE WHERE Name="rasman" set startmode="manual"
WMIC SERVICE WHERE Name="trustedinstaller" set startmode="auto"
net start sdrsvc
net start vss
net start rpcss
net start eventsystem
net start winmgmt
net start msiserver
net start bfe
net start trustedinstaller
WMIC SERVICE WHERE Name="windefend" CALL ChangeStartMode "automatic"
WMIC SERVICE WHERE Name="windefend" CALL startservice
WMIC SERVICE WHERE Name="securityhealthservice" CALL ChangeStartMode "manual"
WMIC SERVICE WHERE Name="securityhealthservice" CALL startservice
net start windefend
net start mpssvc
net start mpsdrv
"%WINDIR%\SYSTEM32\lodctr.exe" /R
"%WINDIR%\SysWOW64\lodctr.exe" /R
"%WINDIR%\SYSTEM32\lodctr.exe" /R
"%WINDIR%\SysWOW64\lodctr.exe" /R
bitsadmin /list /allusers
bitsadmin /reset /allusers
Winmgmt /salvagerepository
Winmgmt /resetrepository
Winmgmt /resyncperf
Endbatch:
startpowershell:
# 10-26-2022 M. Naggar
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiVirus" -Type DWORD -Value 0 –Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Type DWORD -Value 0 –Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "PUAProtection" -Type DWORD -Value 1 –Force
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableBehaviorMonitoring" -force
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableOnAccessProtection" -force
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableScanOnRealtimeEnable" -force
Set-Service -Name windefend -StartupType Automatic -force
Get-Service windefend | Select-Object -Property Name, StartType, Status
Set-Service -Name securityhealthservice -StartupType manual -force
Get-Service securityhealthservice | Select-Object -Property Name, StartType, Status
Set-MpPreference -CheckForSignaturesBeforeRunningScan $true -Force
Set-MpPreference -DisableArchiveScanning $false -Force
Set-MpPreference -DisableBehaviorMonitoring $false -Force
Set-MpPreference -DisableEmailScanning $False -Force
Set-MpPreference -DisableIOAVProtection $false -Force
Set-MpPreference -DisablePrivacyMode $true -Force
Set-MpPreference -DisableRealtimeMonitoring $false -Force
Set-MpPreference -MAPSReporting Advanced -Force
Set-MpPreference -PUAProtection enabled -Force
Set-MpPreference -SignatureScheduleDay Everyday -Force
Set-MpPreference -DisableRemovableDriveScanning $false -Force
Set-MpPreference -SubmitSamplesConsent SendSafeSamples
# Reset and check Secure Health status
Get-AppxPackage Microsoft.SecHealthUI -AllUsers | Reset-AppxPackage
Get-AppxPackage Microsoft.SecHealthUI -AllUsers|select Name, Status
# Check if these services are running
Get-Service mbamservice, Windefend, SecurityHealthService, wscsvc, mpsdrv, mpssvc, bfe, WdNisSvc, WdNisDrv, sense, winmgmt, rpcss, RpcEptMapper, bits, cryptsvc, wuauserv, dcomlaunch | Select Name, DisplayName, Status, starttype
EndPowerShell:
startpowershell:
Write-Output "updating"
Update-MpSignature
Write-Output "scanning"
Start-MpScan -ScanType QuickScan
Remove-MpThreat
Start-MpScan -ScanType customScan -ScanPath "%userprofile%\AppData\Local"
Remove-MpThreat
Start-MpScan -ScanType customScan -ScanPath "%userprofile\AppData\Roaming"
Remove-MpThreat
EndPowerShell:
startpowershell:
# Check computer status again after setting to make sure changes were applied
Get-MpComputerStatus
Get-MpPreference
Get-MpThreatDetection
# get statuses of services
Get-Service BITS | Select-Object -Property Name, StartType, Status
Get-Service Dhcp | Select-Object -Property Name, StartType, Status
Get-Service EventLog | Select-Object -Property Name, StartType, Status
Get-Service EventSystem | Select-Object -Property Name, StartType, Status
Get-Service mbamservice | Select-Object -Property Name, StartType, Status
Get-Service mpsdrv | Select-Object -Property Name, StartType, Status
Get-Service MpsSvc | Select-Object -Property Name, StartType, Status
Get-Service msiserver | Select-Object -Property Name, StartType, Status
Get-Service nsi | Select-Object -Property Name, StartType, Status
Get-Service RasMan | Select-Object -Property Name, StartType, Status
Get-Service rpcss | Select-Object -Property Name, StartType, Status
Get-Service SDRSVC | Select-Object -Property Name, StartType, Status
Get-Service sense | Select-Object -Property Name, StartType, Status
Get-Service securityhealthservice | Select-Object -Property Name, StartType, Status
Get-Service SstpSvc | Select-Object -Property Name, StartType, Status
Get-Service TrustedInstaller | Select-Object -Property Name, StartType, Status
Get-Service UsoSvc | Select-Object -Property Name, StartType, Status
Get-Service VSS | Select-Object -Property Name, StartType, Status
Get-Service wdnissvc | Select-Object -Property Name, StartType, Status
Get-Service windefend | Select-Object -Property Name, StartType, Status
Get-Service Winmgmt | Select-Object -Property Name, StartType, Status
Get-Service wscsvc | Select-Object -Property Name, StartType, Status
Get-Service wuauserv | Select-Object -Property Name, StartType, Status
New-NetFirewallRule -DisplayName "Block Inb" -Direction Inbound –LocalPort 135-139, 445, 1234, 3389, 5555 -Protocol tcp -Action Block
New-NetFirewallRule -DisplayName "Block Inb" -Direction Inbound –LocalPort 135-139, 445, 1234, 3389, 5555 -Protocol udp -Action Block
EndPowerShell:
C:\Windows\Temp\*.*
C:\WINDOWS\system32\*.tmp
C:\WINDOWS\syswow64\*.tmp
EmptyTemp:
Reboot:
End::