3
votes

I am trying a install a UWP app using the powershell command

Start-Process powershell " -ExecutionPolicy Unrestricted -NoExit -Command "cd \"C:\Users\Administrator\Documents\Visual Studio 2015\Projects\App3\AppPackages\App3\App3_1.0.0.0_x64_Test`"; & .\Add-AppDevPackage.ps1 -Force`" |Out-File C:\Users\Administrator\Desktop\log.txt" -Verb RunAs -Wait

where AppDevPackage.ps1 is the powershell script provided in the app.

The script runs fine when I run it by using right-click -> run with powershell.But when I try to invoke the script using a jenkins or using a scheduled task the below error is thrown:

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF6, Package could not be registered.

error 0x80070005: Adding a tile failed with unexpected error.

NOTE: For additional information, look for [ActivityId] 5e8c5432-8277-0004-c28f-8c5e7782d201 in the Event Log or use the command line Get-AppxLog -ActivityID 5e8c5432-8277-0004-c28f-8c5e7782d201

At C:\Users\Administrator\Documents\Visual Studio 2015\Projects\App3\AppPackages\App3\App3_1.0.0.0_x64_Test\Add-AppDevPackage.ps1:388 char:13 + Add-AppxPackage -Path $DeveloperPackagePath.FullName -Dep ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (C:\Users\Admini....0.0.0_x64.appx:String) [Add-AppxPac kage], IOException + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddA ppxPackageCommand

I looked the event log as well,even that gives the same error code.I need to run this script for automation,hence can't run this manually.

1
[ComponentModel.Win32Exception]0x80070005 reports that this error means Access Denied.Jeff Zeitlin
I do not get this error when on running it using right click->run as powershell script. Also, I am using an elevated powershell window in automation to run this command,so don't understand why I'm getting this error.Bharath
There is something different about your rights on the system vs. the rights of the user that the script runs under when running as automation. You might need to supply explicit credentials to run under jenkins or as a scheduled task.Jeff Zeitlin

1 Answers

0
votes

I tried all sorts of things but configuring a scheduled task for the powershell script and invoking it from jenkins using the command :

schtasks /run /tn

is the only thing that worked for me.

Also make sure to run the scheduled task with the highest privileges using an user account which has administrative rights.