【发布时间】:2018-10-23 21:10:17
【问题描述】:
我一直在尝试制作一个powershell脚本来检测安装了什么杀毒软件,然后卸载它。
我已经能够检测到使用 WMI 安装了哪些防病毒软件。
但是我找不到通过 powershell 卸载杀毒软件的方法。
有没有办法做到这一点? 希望大家帮忙。
我用来检测杀毒的脚本:
function Get-AntivirusName {
[cmdletBinding()]
param (
[string]$ComputerName = "$env:computername" ,
$Credential
)
BEGIN
{
$wmiQuery = "SELECT * FROM AntiVirusProduct"
}
PROCESS
{
$AntivirusProduct = Get-WmiObject -Namespace "root\SecurityCenter2" -Query $wmiQuery @psboundparameters
[array]$AntivirusNames = $AntivirusProduct.displayName
Switch($AntivirusNames) {
{$AntivirusNames.Count -eq 0}{"No Antivirus installed";Continue}
{$AntivirusNames.Count -eq 1 -and $_ -eq "Windows Defender"} {"Only Windows Defender is installed!";Continue}
{$_ -ne "Windows Defender"} {"Antivirus installed ($_)."}
}
}
END {
}
}
$av = Get-AntivirusName
Add-Type -AssemblyName PresentationFramework
[System.Windows.MessageBox]::Show($av,'Antivirus')
【问题讨论】:
-
您没有显示任何您自己的代码或任何您尝试研究/搜索解决方案的迹象。 (即使代码不起作用,也要始终包含您的代码!)我建议您阅读How to Ask 和question checklist,因为目前您的问题缺少提出问题时所期望的基础知识。您的问题可能会被否决并关闭,直到您包含基础知识。
-
我还没有做任何事情来做这件事,因为我找不到做这件事的方法。我确实有一个检测防病毒软件的代码,但我认为谈论你可以做到这一点的方法并不重要。如果我错了,我的错
标签: powershell uninstallation antivirus