# WMI object refreshing net stop winmgmt /y winmgmt /resetrepository net start winmgmt # retriving GUID for ESET $eset = Get-CimInstance -ClassName Win32_Product | Where-Object { $_.Name -like "*ESET*" } $esetVersion = $eset.name $Win32_Product_query = "SELECT * FROM AntivirusProduct WHERE displayName = '$esetVersion'" $SecurityCenter2_query = Get-WmiObject -Namespace "root\SecurityCenter2" -Query "SELECT * FROM AntivirusProduct WHERE displayName = 'ESET Endpoint Security'" $SecurityCenter2_query2 = Get-WmiObject -Namespace "root\SecurityCenter2" -Query "SELECT * FROM AntivirusProduct WHERE displayName = 'ESET Security'" if ($eset) { # display GUID $eset | Select-Object Name, IdentifyingNumber # ESET deinstallation $msiGuid = $eset.IdentifyingNumber $msiexecArgs = "/x $msiGuid /quiet /norestart" Start-Process msiexec.exe -ArgumentList $msiexecArgs -Wait Write-Host "ESET zostal‚ pomyslnie odinstalowany." } else { Write-Host "ESET nie zostal znaleziony w tym systemie." -BackgroundColor Green; } if ($SecurityCenter2_query) { $SecurityCenter2_query | Remove-WMIObject Write-Host "Znaleziono wpis ESET Endpoint Security w przestrzeni nazw root\SecurityCenter2. Wpis został usunięty" -BackgroundColor Green; } if ($SecurityCenter2_query2) { $SecurityCenter2_query2 | Remove-WMIObject Write-Host "Znaleziono wpis ESET Security w przestrzeni nazw root\SecurityCenter2. Wpis został usunięty" -BackgroundColor Green; }