简体   繁体   English

PowerShell Core 和 AppX 包管理

[英]PowerShell Core and AppX package management

I am using PowerShell 6.2 preview at the moment.我目前正在使用 PowerShell 6.2 预览版。 In my script I am trying to do stuff with Windows 10 apps.在我的脚本中,我试图用 Windows 10 应用程序做一些事情。 To be able to use commands like Get-AppxPackage , I need to import Windows modules from previous PowerShell like so:为了能够使用像Get-AppxPackage这样的命令,我需要像这样从以前的 PowerShell 导入 Windows 模块:

Import-Module C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Appx\Appx.psd1 -SkipEditionCheck 

Import-Module C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dism\dism.psd1 -SkipEditionCheck 

Does PowerShell core has its own modules to work with this? PowerShell 核心是否有自己的模块来处理这个问题? I found Get-Package for example, but that does not give me anything.例如,我找到了Get-Package ,但这并没有给我任何东西。

Since this is one of the top search results for PowerShell Core Get-AppxPackage , I'm going to take the information from the link provided in the comments and provide an answer, with example.由于这是PowerShell Core Get-AppxPackage的热门搜索结果之一,因此我将从评论中提供的链接中获取信息并提供答案,例如。

As LangsGalgEnRad pointed out in the comments, it's easiest just to do this from Windows PowerShell, but ultimately that's just-shy-of-deprecated at this point, with Microsoft stating that there are to be no more fixes or changes other than critical security issues.正如 LangsGalgEnRad 在评论中指出的那样,最简单的方法是从 Windows PowerShell 中执行此操作,但最终这在这一点上已被弃用,微软表示除了关键的安全问题外,没有更多的修复或更改. That said, it's still (afaik) universally available in Windows installations.也就是说,它仍然(afaik)在 Windows 安装中普遍可用。

But for those of us who want to follow Microsoft's advice to use PowerShell Core, LangsGalgEnRad also points out in the comments the WindowsCompatibility module from Microsoft.但是对于我们这些想要遵循 Microsoft 建议使用 PowerShell Core 的人来说,LangsGalgEnRad 还在评论中指出了 Microsoft 的WindowsCompatibility模块 Reading the blog post, this seems a bit safer than importing a Windows module (eg AppX ) from PowerShell Core, since among other things ...阅读博客文章,这似乎比从 PowerShell Core 导入 Windows 模块(例如AppX )更安全,因为除其他外...

WindowsCompatibility is very careful to not overwrite native PowerShell core commands. WindowsCompatibility非常小心,不会覆盖本机 PowerShell 核心命令。

To install from PowerShell Gallery:从 PowerShell 库安装:

Install-Module WindowsCompatibility 

Example usage for AppX : AppX示例用法:

Import-Module WindowsCompatibility
Import-WinModule AppX
Get-AppxPackage

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PowerShell:如何从.appx package 路径获取身份信息? - PowerShell : How to Get Indentity information from .appx package path? 通过Jenkins通过Powershell插件安装appx - Install appx through Powershell Plugin via Jenkins PowerShell,以编程方式检查是否安装了商店应用程序 (.appx) - PowerShell, programmatically check if a Store App (.appx) is installed 通过PowerShell远程安装Windows 8应用(appx)? - Install Windows 8 app (appx) remotely via PowerShell? UWP:无法安装 appx 或 appxbundle 包 - UWP: Cannot install appx or appxbundle package Visual Studio For Mac 无法运行带有 Nuget 包管理扩展的 Powershell - Visual Studio For Mac cannot run Powershell with Nuget Package Management extension PowerShell 包管理 - 存储库 vs 提供者 vs 源代码 - PowerShell Package Management - Repository vs Provider vs Source 如何使用 PowerShell 包管理删除 Python 安装? - How do I remove Python installations with PowerShell Package Management? 使用Publish-Module将Powershell模块发布到VSTS包管理 - Publishing Powershell Modules to VSTS Package Management using Publish-Module Windows 10 IoT核心PowerShell磁盘管理命令 - Windows 10 IoT Core PowerShell Disk Management Commands
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM