Hi
Before running the script, make sure to replace the following placeholders:
Replace "Computer1", "Computer2", "Computer3"
with the names or IP addresses of the target computers. You can add more computer names to the array if needed.
Replace "{GUID_of_Trend_Micro_Agent.msi}"
with the actual GUID of the Trend Micro Agent MSI file. You can typically find the GUID in the registry under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
key.
Ensure that you have PowerShell remoting enabled on the remote computers, and that you have the necessary administrative privileges to execute remote commands.
When you run the script, it will iterate through the list of computers, connect to each computer remotely, and execute the uninstallation command for the Trend Micro agent. It will provide output indicating the success or failure of the uninstallation process on each computer.
the script
$computers = "Computer1", "Computer2", "Computer3" # Replace with the names or IP addresses of the target computers
$uninstallScript = {
# Uninstall Trend Micro agent
$uninstallArgs = "/S /v/qn"
$uninstallCommand = "msiexec.exe /x {0} {1}" -f "{GUID_of_Trend_Micro_Agent.msi}", $uninstallArgs
Start-Process -FilePath "cmd.exe" -ArgumentList "/c", $uninstallCommand -Wait
}
# Loop through the list of computers
foreach ($computer in $computers) {
Write-Host "Uninstalling Trend Micro agent from $computer"
try {
# Invoke the script block on each remote computer
Invoke-Command -ComputerName $computer -ScriptBlock $uninstallScript -ErrorAction Stop
Write-Host "Uninstallation completed successfully on $computer"
} catch {
Write-Host "Failed to uninstall Trend Micro agent on $computer. Error: $($_.Exception.Message)"
}
}