How To Use Powershell To Clean My Computer
Posey's Tips & Tricks
How To Utilise PowerShell To Uninstall an Application
For what seems like forever, Microsoft has given us an option inside the Control Panel to uninstall unwanted applications. But while using the Command Console to uninstall an application works fine (nigh of the fourth dimension), the process isn't exactly scalable.
If yous need to remove a certain application from a drove of PCs, then it is probable going to be easier washed using PowerShell. Let me testify you how it's washed.
In the involvement of keeping things simple, I'm going to show you how to employ PowerShell to remove an awarding from a unmarried PC. However, this technique can hands exist adapted for multiple machines.
The first matter that you demand to practice is get a listing of the applications that are installed on the machine. The control for doing so is:
Get-WmiObject -Class Win32_Product | Select-Object -Property Proper name
Later several seconds, this control will produce a list of most of the applications that are installed on the PC. You lot tin see an example of this in Figure 1.
Once you take generated a listing of the applications that are installed on the PC, the side by side social club of business concern is to locate the listing for the application that you desire to uninstall. You will need to find the awarding'due south exact name as displayed within PowerShell. (I will be the first to admit that the listing that PowerShell generates tin be a chip overwhelming, even on a PC that has a minimal number of applications installed. I am going to talk nearly some means to narrow downwards the list in a separate column.)
One time you know the application'due south name, removing the application is a relatively straightforward process. Yous will demand to create a variable and map information technology to the awarding that y'all want to remove. From there, you can straight an uninstall instruction to the variable. Here is how the procedure works.
Permit'south suppose that you wanted to remove an application called Free Tools. Every bit previously mentioned, the first step in making this happen is to map a variable to the application. Here is the command that you would use to map a variable to the Free Tools awarding.
$MyApp = Get-WmiObject -Class Win32_Product | Where-Object{$_.Proper noun -eq "Gratis Tools"}
Now you can uninstall the application by calling the Uninstall method. Here is the control:
$MyApp.Uninstall()
The technique that I merely showed you is the generally accepted way of removing applications from a Windows desktop using PowerShell. Sometimes, notwithstanding, you lot will find that there are applications listed in the Windows Control Panel that are not listed when you run the Become-WmiObject cmdlet. In those situations, y'all will have to use a different arroyo.
If y'all look at Figure 2, you lot can see that the first application listed within Command Panel is called Free Tools Launcher.
If you look at Figure 3, nevertheless, you lot can meet that PowerShell seems to know zero of this application.
The workaround for this trouble is to use the Become-Package cmdlet. If I wanted to find the application named Gratis Tools Launcher, for example, I would utilize the following control:
Get-Bundle -Provider Programs -IncludeWindowsInstaller -Name "Gratis Tools Launcher"
As y'all can come across, PowerShell is able to locate the Gratuitous Tools Launcher in this way. In fact, if you want PowerShell to brandish all of the various programs listed within the Command Console, yous can merely supersede the program proper name with an asterisk.
The last step in the process is to uninstall the package. For this, Microsoft conveniently provides a cmdlet called Uninstall-Package. Most of the fourth dimension, y'all can probably get away with specifying the -Name parameter, followed by the packet name. In some cases, though, the Uninstall-Package cmdlet can exist a bit finicky, and you may need to experiment with some of its other parameters. You tin detect the documentation for this cmdlet hither.
About the Writer
Brien Posey is a 20-time Microsoft MVP with decades of IT experience. As a freelance author, Posey has written thousands of manufactures and contributed to several dozen books on a wide variety of Information technology topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and health care facilities. He has too served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. In addition to his continued work in Information technology, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from infinite. You can follow his spaceflight training on his Web site.
Source: https://redmondmag.com/articles/2019/08/27/powershell-to-uninstall-an-application.aspx
Posted by: smithcoulp1969.blogspot.com
0 Response to "How To Use Powershell To Clean My Computer"
Post a Comment