Is there a simple way to hook into the standard 'Add or Remove Programs' functionality using PowerShell to uninstall an existing application? Or to check if the application is installed?
相关问题
- How does the setup bootstrapper detect if prerequi
- How to Debug/Register a Permanent WMI Event Which
- Wix: How can I set, at runtime, the text to be dis
- Inheritance impossible in Windows Runtime Componen
- How can I do variable substitution in a here-strin
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- C#调用PowerShell的问题
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- EscapeDataString having differing behaviour betwee
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
Here is the PowerShell script using msiexec:
I will make my own little contribution. I needed to remove a list of packages from the same computer. This is the script I came up with.
I hope this proves to be useful.
Note that I owe David Stetler the credit for this script since it is based on his.
Use:
It's not fully tested, but it ran under PowerShell 4.
I've run the PS1 file as it is seen here. Letting it retrieve all the Systems from the AD and trying to uninstall multiple applications on all systems.
I've used the IdentifyingNumber to search for the Software cause of David Stetlers input.
Not tested:
What it does not:
I wasn't able to use uninstall(). Trying that I got an error telling me that calling a method for an expression that has a value of NULL is not possible. Instead I used Remove-WmiObject, which seems to accomplish the same.
CAUTION: Without a computer name given it removes the software from ALL systems in the Active Directory.
Based on Jeff Hillman's answer:
Here's a function you can just add to your
profile.ps1
or define in current PowerShell session:Let's say you wanted to uninstall Notepad++. Just type this into PowerShell:
> uninstall("notepad++")
Just be aware that
Get-WmiObject
can take some time, so be patient!To add a little to this post, I needed to be able to remove software from multiple Servers. I used Jeff's answer to lead me to this:
First I got a list of servers, I used an AD query, but you can provide the array of computer names however you want:
Then I looped through them, adding the -computer parameter to the gwmi query:
I used the IdentifyingNumber property to match against instead of name, just to be sure I was uninstalling the correct application.
For Most of my programs the scripts in this Post did the job. But I had to face a legacy program that I couldn't remove using msiexec.exe or Win32_Product class. (from some reason I got exit 0 but the program was still there)
My solution was to use Win32_Process class:
with the help from nickdnk this command is to get the uninstall exe file path:
64bit:
32bit:
you will have to clean the the result string:
now when you have the relevant program uninstall exe file path you can use this command:
the above commands can also run remotely - I did it using invoke command but I believe that adding the argument -computername can work