Hello, I'm currently working on fixing an issue with a Windows 11 Upgrade for my workplace's fleet. Unfortunately, after the upgrade, one of the programs installed throws a vulnerable driver error due to the new security features introduced in Windows 11. Our solution thus far has been manually uninstalling the program on each machine as we go, however, I would like to automate this task to ease the transition to Windows 11 and reduce workload on our staff responsible for upgrading the machines. I've built a few scripts with the help of some AI tools that allow me to gather the GUID's that correlate with different versions of the program Intel(R) network connections but unfortunately when attempting to use the script built for uninstalling them, I keep having error 1602 pop up. I've tried using both batch and PowerShell solutions, with no luck. Code included below. One for writing out to a CSV with GUID's of the programs needing to be uninstalled and one that reads the same CSV to uninstall. All of these will be deployed through SCCM and I've verified that the scripts are functional, as they are successfully able to uninstall the other program defined in the script.
###########################################################################
Define the output file path on the network drive
$outputFile = "C:\FilePathHere\FilterBatch.csv"
if (-not (Test-Path $outputFile)) {
"Program Name,GUID,Version" | Out-File -FilePath $outputFile -Encoding UTF8
}
Function to collect GUIDs, names, and versions for specified programs
function Collect-ProgramInfo {
param (
[string]$programName
)
$products = Get-WmiObject -Query "SELECT * FROM Win32_Product WHERE Name LIKE '%$programName%'"
foreach ($product in $products) {
$line = "$($product.Name),$($product.IdentifyingNumber),$($product.Version)"
if (-not (Select-String -Path $outputFile -Pattern $line)) {
$line | Out-File -FilePath $outputFile -Append -Encoding UTF8
}
}
}
Collect-ProgramInfo -programName "Intel(R) Network Connections"
Collect-ProgramInfo -programName "Imprivata Connector"
Write-Output "Done! The information has been written to $outputFile"
###########################################################################
$csvFile = "C:\FilePathHere\FilterBatch.csv"
Function to uninstall a program using its GUID
function Uninstall-Program {
param (
[string]$programName,
[string]$guid
)
Write-Output "Attempting to uninstall $programName with GUID $guid"
$uninstallProcess = Start-Process msiexec.exe -ArgumentList "/x $guid /qn /norestart" -Wait -PassThru
if ($uninstallProcess.ExitCode -eq 0) {
Write-Output "Successfully uninstalled $programName"
} else {
Write-Output "Failed to uninstall $programName. Exit code: $($uninstallProcess.ExitCode)"
}
}
Read the CSV file and uninstall the programs
if (Test-Path $csvFile) {
$programs = Import-Csv -Path $csvFile
foreach ($program in $programs) {
Uninstall-Program -programName $program.'Program Name' -guid $program.GUID
}
} else {
Write-Output "CSV file not found: $csvFile"
}
Verify if the programs are still installed
foreach ($program in $programs) {
$installedProgram = Get-WmiObject -Query "SELECT * FROM Win32_Product WHERE IdentifyingNumber = '$($program.GUID)'"
if ($installedProgram) {
Write-Output "$($program.'Program Name') is still installed."
} else {
Write-Output "$($program.'Program Name') has been successfully uninstalled."
}
}
Delete the CSV file if it exists
if (Test-Path $csvFile) {
Remove-Item $csvFile -Force
Write-Output "Deleted the CSV file: $csvFile"
}
3. Restart the Computer
Write-Host "Initiating system restart..."
Restart-Computer -Force -Confirm:$false
###########################################################################
I've also tried to uninstall using the program's exact name, with no success.
# 2. Uninstall Programs Matching Specific Name Pattern
$programName = "Intel(R) Network Connections 21.1.30.0"
$program = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $programName }
if ($program) {
$program.Uninstall()
Write-Host "$programName uninstalled successfully."
} else {
Write-Host "Program not found!"
}
$programName = "Intel(R) Network Connections 23.5.2.0"
$program = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $programName }
if ($program) {
$program.Uninstall()
Write-Host "$programName uninstalled successfully."
} else {
Write-Host "Program not found!"
}
###########################################################################
Results for the above line.
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 1602
PSComputerName :
Intel(R) Network Connections 23.5.2.0 uninstalled successfully.
###########################################################################
Any insights/assistance would be appreciated!