# Help removing package

**URL:** <https://forums.powershell.org/t/help-removing-package/11566>\
**Category:** PowerShell Help\
**Created:** [October 28, 2018, 1:57pm UTC](https://forums.powershell.org/t/help-removing-package/11566 "2018-10-28T13:57:49Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![uinthas](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uinthas](https://forums.powershell.org/u/uinthas)\
**Post date:** [October 28, 2018, 1:57pm UTC](https://forums.powershell.org/t/help-removing-package/11566/1 "2018-10-28T13:57:49Z")

</div>

I have been struggling for hours now trying to figure out how to uninstall programs via powershell

I have tried uninstall-package in every variety I can find, it does nothing even though it acts as if removes it

get-package -providername programs -includewindowsinstaller -name"avast free antivirus" |uninstall -force

also Get-WmiObject -class win32\_product -ComputerName “localhost” does not even list the package. Very frustrating, programs and features removes it just fine, you’d think this would be fairly straight forward in powershell. Need to do this across multiple computers, why I am trying to figure it out on powershell. Sure its got to be more complicated then this, any help would be appreciated.

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [October 28, 2018, 5:35pm UTC](https://forums.powershell.org/t/help-removing-package/11566/2 "2018-10-28T17:35:05Z")

</div>

Usually you find the uninstall strings in the registry and you can invoke this to uninstall applications just like the “programs and features” does it.  
You should search for 64 bit applications in HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and for 32 bit applications in HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall.

---

<div class="post-metadata">

**Author:** ![postanote](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@postanote](https://forums.powershell.org/u/postanote)\
**Post date:** [October 28, 2018, 10:30pm UTC](https://forums.powershell.org/t/help-removing-package/11566/3 "2018-10-28T22:30:23Z")

</div>

Did you install this from the MS Store or from somewhere else.

If it was from the store, then it’s …

Get-AppxPackage | RemoveAppxPackage

… there are lots of articles all over the web on the topic … Example(s) …

> How to uninstall a Windows Store app using PowerShell 
> 
> [https://answers.microsoft.com/en-us/windows/forum/windows\_8-winapps/how-to-uninstall-a-windows-store-app-using/85ecc099-3de0-406e-a629-8c6c83ef8abe](https://answers.microsoft.com/en-us/windows/forum/windows_8-winapps/how-to-uninstall-a-windows-store-app-using/85ecc099-3de0-406e-a629-8c6c83ef8abe)
> 
> > **[How to uninstall apps using PowerShell on Windows 10 - Pureinfotech](https://pureinfotech.com/uninstall-apps-powershell-windows-10/)**
> >
> > These steps will help you uninstall Windows 10 apps, including Mail, Store, Xbox, etc., using PowerShell when not working or don't want them.

… and there are already scripts / tools for this, that is if you don’t want to write them yourself.

> Windows 10 Store Apps Uninstaller (PowerShell/WinForms) If you no longer need an app, then you could use Windows 10 Store Apps Uninstaller to remove it and free up space on the drive. https://gallery.technet.microsoft.com/scriptcenter/Windows-10-Store-Apps-5f60b9e3/view/Discussions
> 
> Remove Windows Store apps in Windows 8, Windows 8.1 and Windows 10  
> This script can be used to remove multiple Windows Store apps from a user account in Windows 8, Windows 8.1 and Windows 10. It provides a list of installed Windows Store apps. You can specify the application IDs, and remove them all at
> 
> > **[Browse code samples](https://learn.microsoft.com/en-us/samples/browse/?redirectedfrom=TechNet-Gallery)**
> >
> > Get started with Microsoft developer tools and technologies. Explore our samples and discover the things you can build.

Otherwise the registry uninstall location pointed to by Olaf and avoid using win32\_product at all costs. It does some unwanted things, several articles on the web about that as well.

---

<div class="post-metadata">

**Author:** ![uinthas](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uinthas](https://forums.powershell.org/u/uinthas)\
**Post date:** [October 29, 2018, 10:00am UTC](https://forums.powershell.org/t/help-removing-package/11566/4 "2018-10-29T10:00:23Z")

</div>

Thanks for the help, I have it figured out. Running into a new problem, I have created a .bat file to install my new AV. I have created the domain policy’s to enter-pssession and that works fine. However once I’m on the remote computer and I try it execute the .bat I get permission denied. I have also tried to use invoke-command on the remote pc with the same error. cmdlt I am trying to run is (start-process -computername -filepath) with and without -credentials. I am a domain admin in the network.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [October 29, 2018, 12:11pm UTC](https://forums.powershell.org/t/help-removing-package/11566/5 "2018-10-29T12:11:23Z")

</div>

There is unfortunately little to no chance for us to help you without seeing your code. If you post code please format it as code. Thanks.  
You can edit your post to include the code if you want.

---

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [October 29, 2018, 1:53pm UTC](https://forums.powershell.org/t/help-removing-package/11566/6 "2018-10-29T13:53:54Z")

</div>

Are you admin on the remote computer? Is remote powershell enabled (can be a not easy task)?

---

<div class="post-metadata">

**Author:** ![uinthas](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uinthas](https://forums.powershell.org/u/uinthas)\
**Post date:** [October 29, 2018, 2:06pm UTC](https://forums.powershell.org/t/help-removing-package/11566/7 "2018-10-29T14:06:09Z")

</div>

[quote quote=119751]Are you admin on the remote computer? Is remote powershell enabled (can be a not easy task)?

[/quote]  
It is domain joined so yes I am an admin on the computer. Not sure what you mean by remote powershell, I have my GP set to “allow remote server management through WinRM”, appropriate firewall ports opened and WinRM server starting automatically on pc’s.

---

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [October 29, 2018, 2:11pm UTC](https://forums.powershell.org/t/help-removing-package/11566/8 "2018-10-29T14:11:34Z")

</div>

Does this work?

```
invoke-command computername { pwd }
```

---

<div class="post-metadata">

**Author:** ![neemobeer](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/neemobeer/32/4087_2.png) [@neemobeer](https://forums.powershell.org/u/neemobeer)\
**Post date:** [October 29, 2018, 2:22pm UTC](https://forums.powershell.org/t/help-removing-package/11566/9 "2018-10-29T14:22:59Z")

</div>

Is the batch file or AV installer you’re trying to run on different remote system? Sounds like you’re running into the double-hop problem.

---

<div class="post-metadata">

**Author:** ![uinthas](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uinthas](https://forums.powershell.org/u/uinthas)\
**Post date:** [October 29, 2018, 2:31pm UTC](https://forums.powershell.org/t/help-removing-package/11566/10 "2018-10-29T14:31:10Z")

</div>

[quote quote=119772]Is the batch file or AV installer you’re trying to run on different remote system? Sounds like you’re running into the double-hop problem.

[/quote]

Yes, the .bat file resides on a server share, I have heard of this issue but not sure what it means?

---

<div class="post-metadata">

**Author:** ![uinthas](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uinthas](https://forums.powershell.org/u/uinthas)\
**Post date:** [October 29, 2018, 2:33pm UTC](https://forums.powershell.org/t/help-removing-package/11566/11 "2018-10-29T14:33:18Z")

</div>

[quote quote=119761][/quote]

Yes it does

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [October 29, 2018, 5:37pm UTC](https://forums.powershell.org/t/help-removing-package/11566/12 "2018-10-29T17:37:48Z")

</div>

You could shorten all this when you simply post your code. 😉 Or is it a secret?

---

<div class="post-metadata">

**Author:** ![uinthas](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uinthas](https://forums.powershell.org/u/uinthas)\
**Post date:** [October 29, 2018, 7:59pm UTC](https://forums.powershell.org/t/help-removing-package/11566/13 "2018-10-29T19:59:51Z")

</div>

[quote quote=119820]You could shorten all this when you simply post your code. 😉 Or is it a secret?

[/quote]

Your right I should have posted it to begin with, sorry:

launch powershell as administrator \>

enter-pssession -computername d1 (this works)\>

[d1]: ps c:&gt;start-process -filepath “\dc-server1\softwaredeploy\install.bat” (access denied)

[d1]: ps c:&gt;start-process -filepath “\dc-server1\softwaredeploy\install.bat” -credentials (access denied after entering local and domain credentials)

invoke-command -computername “d1” {start-process -filepath “\dc-server1\softwaredeploy\install.bat”} (access denied)

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![alex-aymonier](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alex-aymonier](https://forums.powershell.org/u/alex-aymonier)\
**Post date:** [October 29, 2018, 10:07pm UTC](https://forums.powershell.org/t/help-removing-package/11566/14 "2018-10-29T22:07:30Z")

</div>

This is the classic double hop problem Neemobeer mentioned. You’re remoting from one machine to d1 (1st hop) all okay here. Then your trying to get to \dc-server1 (2nd hop) no go I’m afraid as you have not set d1 to be able to delegate your credentials to DC-server1. Check out this by Ashley Mcglone on how to get this to work.

[https://blogs.technet.microsoft.com/ashleymcglone/2016/08/30/powershell-remoting-kerberos-double-hop-solved-securely/](https://blogs.technet.microsoft.com/ashleymcglone/2016/08/30/powershell-remoting-kerberos-double-hop-solved-securely/)

---

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [October 30, 2018, 12:13pm UTC](https://forums.powershell.org/t/help-removing-package/11566/15 "2018-10-30T12:13:43Z")

</div>

It’s always a good idea to post the complete code and error messages…

---

<div class="post-metadata">

**Author:** ![sanchez](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@sanchez](https://forums.powershell.org/u/sanchez)\
**Post date:** [October 30, 2018, 12:35pm UTC](https://forums.powershell.org/t/help-removing-package/11566/16 "2018-10-30T12:35:55Z")

</div>

I recently did an AV migration and handled it the following way:

1. Create a GPO that pushes out the AV exe and associated scripts out to the machine
2. Create a text file with all the server names you want to push out the AV to
3. Use invoke-command to install the software

My code was something like this

[pre]

$x = new-psession -computername (get-content C:\scripts\computers.txt)

invoke-command -session $x -scriptblock {Start-Process -FilePath ‘C:\mcafee\McAfeeAgent5.5.exe’ -ArgumentList ‘/install=agent /silent’}

[/pre]

You could also do something like this, which assumes the script is installed on the machine you are running powershell from

[pre]

$x = new-psession -computername (get-content C:\scripts\computers.txt)

invoke-command -session $x -filepath C:\scripts\installnewAV.ps1

[/pre]

---

<div class="post-metadata">

**Author:** ![uinthas](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uinthas](https://forums.powershell.org/u/uinthas)\
**Post date:** [October 30, 2018, 4:57pm UTC](https://forums.powershell.org/t/help-removing-package/11566/17 "2018-10-30T16:57:06Z")

</div>

I appreciate all the help, that article explained what I was doing wrong. I put the following script together, and it’s working. Hope maybe this helps someone else out.

&nbsp;

$session = New-PSSession -ComputerName d1  
Copy-Item -Path “C:\folder\*.\*” -ToSession $session -Destination ‘c:\windows\temp’

Invoke-Command -Session $session -ScriptBlock {  
c:\windows\temp\install.bat /silent}

Invoke-Command -session $session {Get-ChildItem -Path “c:\windows\temp\install\*.\*” |Remove-Item}

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/help-removing-package/11566/18 "2024-05-16T20:33:46Z")

</div>


