Error Running RemoveAppx command

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.

This forum is a space to discuss coding in PowerShell, and technical issues related to development.

- Question about a licensed SAPIEN product? Post here: Product Support for Registered Users
- Question about a trial SAPIEN product? Post here: Former and Future Customers - Questions
Post Reply
User avatar
B Daring
Posts: 95
Last visit: Tue Jan 07, 2025 2:07 pm
Answers: 2
Has voted: 1 time
Been upvoted: 1 time

Error Running RemoveAppx command

Post by B Daring »

Product: PowerShell Studio 2024 (64 Bit)
Build: v5.8.251
OS: Windows 11.0.22631
PS Version(s): 5.1.22621.1

I have a script and it is setup to be a service. I am trying to run Remove-AppxPackage or Remove-AppxProvisionedPackage and I get the below error. Seems like I have been able to run this without issues until one of the updates I did for Studio.

Code: Select all

System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.TypeInitializationException: The type initializer for 'WinRT.Projections' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
User avatar
brittneyr
Site Admin
Posts: 1836
Last visit: Wed Jan 15, 2025 10:12 pm
Answers: 46
Been upvoted: 37 times

Re: Error Running RemoveAppx command

Post by brittneyr »

[Topic was moved by moderator to PowerShell Forum]
Brittney
SAPIEN Technologies, Inc.
User avatar
brittneyr
Site Admin
Posts: 1836
Last visit: Wed Jan 15, 2025 10:12 pm
Answers: 46
Been upvoted: 37 times

Re: Error Running RemoveAppx command

Post by brittneyr »

Based on the error message, you are missing an assembly.

Based on searching online, I found the following that may be helpful:
https://github.com/AutomatedLab/Automat ... ssues/1670
https://gist.github.com/jborean93/f6f27 ... 3e28f5f660
Brittney
SAPIEN Technologies, Inc.
User avatar
B Daring
Posts: 95
Last visit: Tue Jan 07, 2025 2:07 pm
Answers: 2
Has voted: 1 time
Been upvoted: 1 time

Re: Error Running RemoveAppx command

Post by B Daring »

Thanks Brittney,

But it runs fine in powershell window, just won't run when compiled in Studio
User avatar
B Daring
Posts: 95
Last visit: Tue Jan 07, 2025 2:07 pm
Answers: 2
Has voted: 1 time
Been upvoted: 1 time

Re: Error Running RemoveAppx command

Post by B Daring »

I did the fix in the second link and it worked. So it seems to be a Win11 24H2 problem then.

https://gist.github.com/jborean93/f6f27 ... 3e28f5f660

Thank you :)
Post Reply