feat: add support for targeting software by known GUIDs
This commit is contained in:
@@ -241,6 +241,13 @@ function Invoke-UninstallSoftware {
|
|||||||
# Common printer brands/keywords
|
# Common printer brands/keywords
|
||||||
$brands = @("HP", "Hewlett-Packard", "Canon", "Epson", "Brother", "Xerox", "Kyocera", "Ricoh", "Lexmark", "Konica", "Samsung", "Oki", "Zebra", "Dymo", "Dell")
|
$brands = @("HP", "Hewlett-Packard", "Canon", "Epson", "Brother", "Xerox", "Kyocera", "Ricoh", "Lexmark", "Konica", "Samsung", "Oki", "Zebra", "Dymo", "Dell")
|
||||||
|
|
||||||
|
# Internal Registry of Known Printer App GUIDs (for apps not detected by name)
|
||||||
|
# Format: "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"
|
||||||
|
$knownGuids = @(
|
||||||
|
# Add your GUIDs here, e.g.:
|
||||||
|
# "{12345678-1234-1234-1234-1234567890AB}"
|
||||||
|
)
|
||||||
|
|
||||||
$allSoftware = Get-InstalledSoftware
|
$allSoftware = Get-InstalledSoftware
|
||||||
|
|
||||||
# Use ArrayList to avoid type issues
|
# Use ArrayList to avoid type issues
|
||||||
@@ -249,13 +256,27 @@ function Invoke-UninstallSoftware {
|
|||||||
|
|
||||||
# Filter software list
|
# Filter software list
|
||||||
foreach ($sw in $allSoftware) {
|
foreach ($sw in $allSoftware) {
|
||||||
|
$isMatch = $false
|
||||||
|
|
||||||
|
# Check 1: Brand Keywords
|
||||||
foreach ($brand in $brands) {
|
foreach ($brand in $brands) {
|
||||||
if ($sw.DisplayName -match "(?i)\b$brand\b") { # Case insensitive regex match
|
if ($sw.DisplayName -match "(?i)\b$brand\b") {
|
||||||
# This -match operator was overwriting the old $matches variable!
|
$isMatch = $true
|
||||||
[void]$foundSoftware.Add($sw)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check 2: Known GUIDs
|
||||||
|
if (-not $isMatch) {
|
||||||
|
if ($knownGuids -contains $sw.RegistryKeyName) {
|
||||||
|
$isMatch = $true
|
||||||
|
Write-Host " [+] Found by GUID: $($sw.DisplayName)" -ForegroundColor Cyan
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isMatch) {
|
||||||
|
[void]$foundSoftware.Add($sw)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($foundSoftware.Count -eq 0) {
|
if ($foundSoftware.Count -eq 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user