Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

[Question] Will this work to uninstall multiple applications?

$
0
0

Hello /r/PowerShell!

I don’t have the capacity to test this outside of production, so I’d be glad if someone more experienced could look at that script and tell me if it will do what I need it to do.

I want to be able to uninstall multiple programs from multiple PCs remotely. Here’s what I have:

$computers = (Read-Host "Enter each PC name (separate with comma, NO SPACE!)").split(',') | % {$_.trim()} $TargetAppIDs = (Read-Host "Please enter the IDs of the applications (separate with comma, NO SPACE!)").split(',') | % {$_.trim()} FOREACH ($computer in $computers) { Write-Host "" Write-Host "Currently running on"$computer -ForegroundColor Yellow FOREACH ($TargetAppID in $TargetAppIDs) { $app = Get-WmiObject -ComputerName $computer -Class Win32_Product | Where-Object {$_.IdentifyingNumber -match $TargetAppID } $app.Uninstall() Write-Host " Uninstalling $TargetAppID" -ForegroundColor Yellow } } 

It’s simple and in my brain it should work fine I just don’t have any safe testing options right now.

Thanks in advance!

submitted by /u/Alaknar
[link] [comments]

The post [Question] Will this work to uninstall multiple applications? appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles