添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hi everybody, I need PowerShell code that retrieves the install location of an Appx package on my Windows 10 system and assigns it to some variable. Let's say,

Get-AppxPackage -Name "Microsoft.AsyncTextService" -AllUsers

gives this output:

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

Then I need PowerShell code that retrieves the install location and assigns it to some variable - so that I can use it elsewhere in my script. I have experimented with piping into "Select-String -AllMatches -Pattern" but that never yielded the desired result. I understand that PowerShell somehow does not work like Unix bash scripting I am used to but I am at a loss at how to solve this. Any help would be greatly appreciated.