Below script to uninstall an application from remote servers (or a number of the remote servers). You can also import the list of computers from a txt file using ($computers = get-content .\computer.txt)
$computers = get-adcomputer -filter ‘OperatingSystem -like “*Windows Server*”‘ -SearchBase “<Server name FQDN”
foreach($comp in $computers){
$computer = $comp.name
$error.clear()
$log = Invoke-Command -ComputerName $computer -ScriptBlock {
$application = Get-WmiObject Win32_Product -filter “Name=’Application name'”
$appl = $application.name
Write-host “Removing $app from Server”
$application.Uninstall()
} |Out-string
if($error[0].Exception -like “*WinRM cannot complete the operation*”) {$status = “Server not accessible”}
elseif($error[0].Exception -like “*null-valued expression*”) {$status = “Application not present”}
Else {$status = “Appllication removal Success”}
Add-content .\Applicationremoval.log -value “$computer;$status”
}