windows - 通过 Jenkins 通过 Powershell 插件安装 appx

标签 windows powershell jenkins appx

我在尝试使用 Powershell -ExecutionPolicy Unrestricted add-appxpackage <path to appx> 安装 appx 时遇到问题在 Jenkins 中使用 Powershell 插件并记录以下错误:

add-appxpackage : Deployment failed with HRESULT: 0x80073CF9, Install failed. Please contact your software vendor. (Exception from HRESULT: 0x80073CF9) Deployment Add operation rejected on package <path to appx> install request because the Local System account is not allowed to perform this operation. NOTE: For additional information, look for [ActivityId] .

据我了解,这个问题主要是因为 Windows 上的 Jenkins 服务安装为 NT Authority\System . (如果我使用 psexec.exe 打开以 Authority\System 身份运行的命令提示符,我会遇到同样的问题。)然后我尝试添加 net localgroup "Administrators" NT Authority\System /add希望该组可以添加为管理员并让我安装 appx,这样我就可以运行测试,但没有成功。现在我被卡住了,我不确定是否真的有办法通过 Jenkins 安装 appx,或者是否有办法通过 Jenkins 以管理员身份调用 Powershell 脚本。我已经通过了几个 SO 链接,但它们似乎都无法解决我面临的问题。任何指针将不胜感激。

最佳答案

不要尝试将 System 添加到 Administrators 组,这是一个受限帐户,不需要管理权限。

而是将 Jenkins 服务更改为以对您尝试执行的操作具有正确权限的用户身份运行。这可能意味着您需要专门为 Jenkins 服务创建一个帐户。

有几种方法可以更改服务帐户,this answer给出以下解决方案:

sc.exe config "Service Name" obj= "DOMAIN\User" password= "password"

关于windows - 通过 Jenkins 通过 Powershell 插件安装 appx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34129631/

相关文章:

windows - Git - 缓慢获取 - 凭证管理器主机提供商

powershell - 在powershell中创建一个具有动态属性名称的类

windows - 使用 powershell 执行卸载字符串

configuration - Jenkins 和JUnit

c - 我应该 IUnknown::Release 使用 DllGetClassObject 创建的接口(interface)吗

android - Flutter:无法解析com.android.support:support-v4:27.1.0

windows - docker -无法计算缓存键: not found - runs fine in visual studio

Powershell 多行文本框输出

jenkins - 如何从命令行运行 Jenkins 构建?

Jenkins : Copy artifacts from Multibranch pipeline