How to retrieve Appx package install location in PowerShell programmatically

Private Coder 75 Reputation points
2023-02-20T13:27:13.0533333+00:00

Hi, PowerShell newbie here, I need PowerShell scripting code that returns me the install location of an Appx package on my Windows 10 system. Let's say I get something like this returned by Get-AppxPackage -Name "Microsoft.AsyncTextService" -AllUsers:

Name                   : Microsoft.AsyncTextService
Publisher              : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture           : Neutral
ResourceId             :
Version                : 10.0.19041.1023
PackageFullName        : Microsoft.AsyncTextService_10.0.19041.1023_neutral__8wekyb3d8bbwe
InstallLocation        : C:\Windows\SystemApps\Microsoft.AsyncTextService_8wekyb3d8bbwe
IsFramework            : False
PackageFamilyName      : Microsoft.AsyncTextService_8wekyb3d8bbwe
PublisherId            : 8wekyb3d8bbwe
PackageUserInformation : {S-1-5-21-2697059947-1034656983-1047649410-1001 [Admin]: Installed, S-1-5-21-2697059947-1034656983-1047649410-1003 [User 1]: Installed}
IsResourcePackage      : False
IsBundle               : False
IsDevelopmentMode      : False
NonRemovable           : True
IsPartiallyStaged      : False
SignatureKind          : System
Status                 : Ok

In this example, what I need is some PowerShell code that assigns me the string, "C:\Windows\SystemApps\Microsoft.AsyncTextService_8wekyb3d8bbwe", to some variable - so that I can use it elsewhere in my PowerShell script. I experimented with piping into 'Select-String -Pattern "C:\\\Program"' and similar things but that never seemed to work. Somehow I never got the expected string returned from such pattern matching attempts.

Windows for business | Windows Server | User experience | PowerShell
{count} votes

3 answers

Sort by: Most helpful
  1. Andreas Baumgarten 123.6K Reputation points MVP Volunteer Moderator
    2023-02-21T17:17:02.01+00:00

    Hi @Private Coder ,

    if you want just the install location of the Appx package in a variable you can try this:

    $installPath = (Get-AppxPackage -Name "Microsoft.AsyncTextService" -AllUsers).InstallLocation
    $installPath
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards Andreas Baumgarten

    3 people found this answer helpful.

  2. Limitless Technology 44,766 Reputation points
    2023-02-21T17:07:42.8766667+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query

    To retrieve the Appx package install location in PowerShell programmatically [1], you can use the Get-AppxPackage cmdlet. This cmdlet will list all the Appx packages installed for the current user [2], as well as the install location for each package. Here is an example of how to use this cmdlet:

    Get-AppxPackage | Select Name, InstallLocation

    This command will list the name and installation location of all the Appx packages installed on the current user's machine

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.