Uninstall of Intel(R) Network Connections through Powershell/Batch

Nate Lindell 0 Reputation points
2024-12-27T15:23:16.0566667+00:00

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"

Write the CSV header if the output file does not exist

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 program information for specified programs

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!

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2024-12-27T21:04:46.5433333+00:00

    At the very start of your script you ensure that the CSV file exists by writing the header record to the file if the file doesn't exist. You never verify that the CSV file contains more than the header record after calling the Collect-ProgramInfo function.

    Later, you import the (possibly empty, except for the header record) CSV and loop over the (possibly empty) set of rows in $programs.

    Also, the Get-WmiObject Win32_Process only retrieves software installed with WMI.

    To remove the "Intel(R) Network Connections" you'd probably have to not be using the NIC(s) (i.e., terminate any network connections (browsers, file shares, etc.). And, to reinstall it, you should have the package available on the target machine because you may have no network connection after that!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.