Link to home
Start Free TrialLog in
Avatar of CaussyR

asked on

Uninstall Applications

I have to uninstall the McAfee agent across 100s of servers and reinstall the agent.

I have tried to investigate doing this by powershell :

$Hostname = "UK120808"
invoke-expression "cd c:\Program Files (x86)\McAfee\Common Framework\"
invoke-item "frminst.exe /forceuninstall"

Everytime I run the sccript the following error appears :

The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
 or if a path was included, verify that the path is correct and try again.

Invoke-Item : Cannot find path 'C:\Program Files (x86)\McAfee\Common Framework\frminst.exe \forceuninstall' because it does not exist
At E:\Powershell\UninstallMcAfeeAgent.ps1:9 char:12
+ invoke-item <<<<  "frminst.exe /forceuninstall"

TO uninstalll the agent manually, its just asimple case of running :

c:\program files (x86)\mcafee\common framework\frminst.exe /forceuninstall

Can anyone let em know how to do this via powershell - thanks
Avatar of Barry Cunney
Barry Cunney
Flag of Ireland image

invoke-expression "cd 'c:\Program Files (x86)\McAfee\Common Framework'"
Avatar of SubSun
If PSRemoting enabled on remote servers then you can use  Invoke-Command to execute the command on remote server.
$scriptblock = {& 'c:\program files (x86)\mcafee\common framework\frminst.exe' /forceuninstall}
Invoke-Command -scriptblock $scriptblock -computername "LocalHost"

Open in new window

Else you can try with PsExec ..
Avatar of CaussyR


I tried the following using WMI :

$classkey="IdentifyingNumber=`"`{2AAB21C2-4CDA-4189-A0EC-5ED666113F84`}`",Name=`"McAfee Agent`""


foreach($server in $servers)
      { ([wmi]"\\$server\root\cimv2:Win32_Product.$classKey").uninstall() }

When I run then script I get the following error :

Cannot convert value "\\\root\cimv2:Win32_Product.IdentifyingNumber="{2AAB21C2-4CDA-4189-A0EC-5ED666113F84}",Name="McAfee
Agent"" to type "System.Management.ManagementObject". Error: "Invalid parameter "
At C:\Users\tester\AppData\Local\Temp\effd2d72-f90e-44a2-89d0-8f94d6fbd7fb.ps1:5 char:10
+     { ([wmi] <<<< "\\$server\root\cimv2:Win32_Product.$classKey").uninstall() }
    + CategoryInfo          : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException
Avatar of SubSun
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial