Solved Uninstalling Programs (Windows 10) Using Powershell
-
Ive seen multiple people using
$app= Get-WmiObject =class win32 product | where-object { $._Name- Match "*Program Name*" } $app Unistall()
But when ever I do it i get this error :
$app uninstall() is not an expression
Does anyone know anything about this?
any help appreciatedThis is for personal computer uninstalling to reinstall a program thats causing me problems before the upgrade and now trying to get it to work again.
-
Try this instead:
(Get-WmiObject -Class Win32_Product -Filter "Name='Oracle VM VirtualBox'" -ComputerName . ).Uninstall()
-
I could go the GUI way but I want to try uninstalling through Powershell to get more of the CLI feel (thinking about making my way to linux completely eventually)
Everything ive seen says that this should working in Powershell ISE. Screen shots to come.
-
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
$app uninstall() is not an expression
You are missing the period.
$app.Uninstall()
It's a method.
-
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
$app uninstall() is not an expression
You are missing the period.
$app.Uninstall()
It's a method.
-
$app is a variable, in PowerShell that makes it an object so it can have methods. On its own, you can't just call a variable and expect some action. Look at the first like, you have $app = some stuff. That's like in math, x = the square root of 9. X doesn't "do" anything, it just represents a number.
Same here. $app is a variable like x, it just represents the identity of the application that you want to remove.
But since it is an object, that inherits from some class that has methods for handling application removal, you can use its "uninstall()" method to uninstall it. A method is called via the dot notation.
So $app.methodName() allows the methodName() to take some action on the object $app
-
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
$app uninstall() is not an expression
You are missing the period.
$app.Uninstall()
It's a method.
That's a totally different error. This is that your Get-WmiObject call is incorrect.
-
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
$app uninstall() is not an expression
You are missing the period.
$app.Uninstall()
It's a method.
That's a totally different error. This is that your Get-WmiObject call is incorrect.
I noticed that as well
-
Try this instead:
(Get-WmiObject -Class Win32_Product -Filter "Name='Oracle VM VirtualBox'" -ComputerName . ).Uninstall()
-
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
-
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
I did install via Chocolatey does that have something to do with it?
-
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
I did install via Chocolatey does that have something to do with it?
Yes, a lot. Chocolatey is its own package management system. So Get-WmiObject knows nothing about it and can't interact with it. It's not "installed" in Windows terms, it's just "sitting there."
To uninstall something managed with Chocolatey you just do...
choco uninstall packagename
-
Remember, Chocolatey brings simple package management to Windows via repos the way that all of the non-Windows world has worked for decades. None of that bizarre, complicated need to script basic tasks, it's just a trivial command away to install, update, uninstall, etc.
-
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
I did install via Chocolatey does that have something to do with it?
Yes, a lot. Chocolatey is its own package management system. So Get-WmiObject knows nothing about it and can't interact with it. It's not "installed" in Windows terms, it's just "sitting there."
To uninstall something managed with Chocolatey you just do...
choco uninstall packagename
That would make a whole lot of sense.
-
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Remember, Chocolatey brings simple package management to Windows via repos the way that all of the non-Windows world has worked for decades. None of that bizarre, complicated need to script basic tasks, it's just a trivial command away to install, update, uninstall, etc.
And now that you say something I remember there being a time I had to unistall... I over complicated that.
-
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
I did install via Chocolatey does that have something to do with it?
Yes, a lot. Chocolatey is its own package management system. So Get-WmiObject knows nothing about it and can't interact with it. It's not "installed" in Windows terms, it's just "sitting there."
Actually, no. It is almost always there for windows to see. Because most chocolatey installs actually use the default windows installer. Just with a /silent switch (or whatever is appropriate).
-
@jaredbusch said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
I did install via Chocolatey does that have something to do with it?
Yes, a lot. Chocolatey is its own package management system. So Get-WmiObject knows nothing about it and can't interact with it. It's not "installed" in Windows terms, it's just "sitting there."
Actually, no. It is almost always there for windows to see. Because most chocolatey installs actually use the default windows installer. Just with a /silent switch (or whatever is appropriate).
Oh, I thought it never did that. I must have just worked with a few that didn't.
-
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@jaredbusch said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
I did install via Chocolatey does that have something to do with it?
Yes, a lot. Chocolatey is its own package management system. So Get-WmiObject knows nothing about it and can't interact with it. It's not "installed" in Windows terms, it's just "sitting there."
Actually, no. It is almost always there for windows to see. Because most chocolatey installs actually use the default windows installer. Just with a /silent switch (or whatever is appropriate).
Oh, I thought it never did that. I must have just worked with a few that didn't.
Chocolatey does not put anything in there. But since most packages are just using the normal installer in silent mode, it is generally there.
-
@jaredbusch said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@jaredbusch said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
I did install via Chocolatey does that have something to do with it?
Yes, a lot. Chocolatey is its own package management system. So Get-WmiObject knows nothing about it and can't interact with it. It's not "installed" in Windows terms, it's just "sitting there."
Actually, no. It is almost always there for windows to see. Because most chocolatey installs actually use the default windows installer. Just with a /silent switch (or whatever is appropriate).
Oh, I thought it never did that. I must have just worked with a few that didn't.
Chocolatey does not put anything in there. But since most packages are just using the normal installer in silent mode, it is generally there.
Makes sense.
-
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@jaredbusch said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@jaredbusch said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
I did install via Chocolatey does that have something to do with it?
Yes, a lot. Chocolatey is its own package management system. So Get-WmiObject knows nothing about it and can't interact with it. It's not "installed" in Windows terms, it's just "sitting there."
Actually, no. It is almost always there for windows to see. Because most chocolatey installs actually use the default windows installer. Just with a /silent switch (or whatever is appropriate).
Oh, I thought it never did that. I must have just worked with a few that didn't.
Chocolatey does not put anything in there. But since most packages are just using the normal installer in silent mode, it is generally there.
Makes sense.
It's like that with every package I've installed. One example is salt minion. If you install that with chocolatey, then uninstall it via Windows control panel, then try installing it again with Chocolatey, Chocolatey thinks it's still installed because doing it through Windows never tells Chocolatey it was installed. You have to use the force switch to install it again with Chocolatey.
The same goes for all Chocolatey packages I've used... 7zip, Firefox, Chrome, etc.
-
@obsolesce said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@jaredbusch said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@jaredbusch said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
@wrcombs said in Uninstalling Programs (Windows 10) Using Powershell:
@scottalanmiller said in Uninstalling Programs (Windows 10) Using Powershell:
Now, I thought that you had installed this via Chocolatey, not the Windows installer, though. Based on other threads.
I did install via Chocolatey does that have something to do with it?
Yes, a lot. Chocolatey is its own package management system. So Get-WmiObject knows nothing about it and can't interact with it. It's not "installed" in Windows terms, it's just "sitting there."
Actually, no. It is almost always there for windows to see. Because most chocolatey installs actually use the default windows installer. Just with a /silent switch (or whatever is appropriate).
Oh, I thought it never did that. I must have just worked with a few that didn't.
Chocolatey does not put anything in there. But since most packages are just using the normal installer in silent mode, it is generally there.
Makes sense.
It's like that with every package I've installed. One example is salt minion. If you install that with chocolatey, then uninstall it via Windows control panel, then try installing it again with Chocolatey, Chocolatey thinks it's still installed because doing it through Windows never tells Chocolatey it was installed. You have to use the force switch to install it again with Chocolatey.
The same goes for all Chocolatey packages I've used... 7zip, Firefox, Chrome, etc.
A bit like deleting files and then the RPM database has no idea what has happened.