Windows users need to perform a virus and malware scan, especially when the system slows down or suspicious activities start appearing. In addition to the traditional antivirus software in Windows, PowerShell is a powerful tool that helps scan for viruses and malware. In this guide, we will explain in detail how you can monitor your Windows system using PowerShell.
What is PowerShell?
PowerShell is a command-line shell and scripting language that comes with the Windows operating system. It is used for system administration and automation.
There are many security commands available in PowerShell that can control Windows Defender or other antivirus tools. This allows you to scan for viruses by running commands without any graphical interface.
How to Scan for Virus in Windows Using PowerShell?
It is easy to scan using Windows Defender with PowerShell. Follow the steps below:
Open PowerShell in Admin mode
Press Windows Key + X and select Windows Terminal (Admin).
If Windows Terminal doesn’t appear, click PowerShell (Admin).
Click Yes when the UAC (User Account Control) prompt appears.
Perform a Quick Scan with Windows Defender
Windows Defender is Windows’ built-in antivirus tool. It can be used to scan via PowerShell.
Command:
Start-MpScan -ScanType QuickScan
This command will start a quick scan and check folders where viruses are more likely to be found.
Perform a Full System Scan
If you think viruses might be hidden deep inside your system, it is better to perform a full scan.
Command:
Start-MpScan -ScanType FullScan
This command will take longer to run because it scans the entire system.
Custom Scan
If you only want to scan a specific folder or drive, use this command:
Command:
Start-MpScan -ScanType CustomScan -ScanPath “C:\Users\YourUsername\Downloads”
Enter the path to scan in “ScanPath“.
Commands to Remove Virus with PowerShell
If Windows Defender finds a virus, you can remove it through PowerShell.
View a List of Detected Threats
Get-MpThreatDetection
This command will give you a list of viruses and malware that Windows Defender has detected.
Clean up viruses
Remove-MpThreat -ThreatID 1,2,3
The “ThreatID” in this will be the IDs of the threats you want to remove. You will get this ID from the Get-MpThreatDetection command.
Update Windows Defender
It is important to keep Windows Defender updated to avoid new viruses and malware. To update it from PowerShell, run this command:
Update-MpSignature
This command will download the latest virus definitions for Windows Defender.
Turn on Windows Defender
If Windows Defender has stopped for some reason, run this command to turn it on again:
Set-MpPreference -DisableRealtimeMonitoring $false
This will turn on the real-time protection of your system again.
Additional security measures
Apart from PowerShell, you can make your system more secure by taking some more security measures:
Keep software updated: Outdated software may contain security vulnerabilities.
Scan untrusted files: Before installing any new software or file, scan it with Windows Defender.
Avoid suspicious emails and websites: Do not open unknown email attachments and avoid visiting suspicious websites.
Keep Windows Firewall on: Never turn off Windows Firewall; it prevents unauthorized network access.
Turn on real-time protection: Turning it off may give viruses a chance to enter the system.
Conclusion
Scanning for viruses and malware using Windows Defender through PowerShell is not only easy, but it is also fast and effective. If your system has slowed down or you suspect that it has a virus, then perform a scan and removal using the PowerShell commands mentioned above.
To keep Windows safe, scan regularly and keep Windows Defender updated.
Want to grow your business organically? Contact us now
Frequently Asked Questions (FAQ)
1. Is it safe to scan for viruses with PowerShell?
Yes, PowerShell is an official Windows tool and works with Windows Defender to safely scan for viruses.
2. How long does a scan take with PowerShell?
A Quick Scan is completed in a few minutes.
A Full Scan may take longer depending on the number of files scanned.
3. Can I scan with a third-party antivirus through PowerShell?
No, PowerShell is designed to control Windows Defender only. However, some third-party antiviruses may provide scripting support.
4. Can I remove detected viruses through PowerShell?
Yes, you can remove detected viruses using the Remove-MpThreat command.
5. If the PowerShell scan does not find any viruses, does it mean my system is completely safe?
No, some advanced malware cannot be detected by Windows Defender. For better protection, perform regular scans and use a firewall and other security tools.
6. How to update Windows Defender using PowerShell command?
You can use the following command:
Update-MpSignature
This will update Windows Defender with the latest virus definitions.
7. Can a specific folder be scanned using PowerShell?
Yes, you can use the Custom Scan command:
Start-MpScan -ScanType CustomScan -ScanPath “C:\YourFolderPath”
8. If Windows Defender is stopped, how to turn it on using PowerShell?
You can turn Windows Defender back on using the following command:
Set-MpPreference -DisableRealtimeMonitoring $false