2015-12-10 24 views
5

Tôi đã cố gắng vô ích để cài đặt ứng dụng toàn cầu Windows 10 với tính năng truy cập từ xa PowerShell. Tôi đã thử tất cả tôi có thể nghĩ đến vì vậy bây giờ tôi đang chuyển sang bạn hy vọng rằng ai đó có thể cung cấp cho tôi một câu trả lời hoặc giải thích là tại sao cách tiếp cận của tôi không hoạt động. Các giải pháp thay thế cũng được đánh giá cao. Về cơ bản những gì tôi muốn làm là có thể cài đặt ứng dụng Windows 10 từ xa và cách tiếp cận của tôi bao gồm tải tệp xuống máy tính đích và sử dụng tính năng truy cập từ xa powershell để chạy cài đặt. Đây là phiên bản được nhúng xuống của tập lệnh của tôi:Cài đặt ứng dụng Windows 10 với quyền truy cập từ xa powershell

$computerName = 'XYZ' 
$userName = 'abc' 
$newCred = Get-Credential "$computerName\$userName" 
$newSession = New-PSSession -ComputerName $computerName -Credential $newCred -ErrorAction Stop 
Invoke-Command -Session $newSession -ErrorAction Stop -Verbose -Scriptblock { 

function installApp($srcDirectory) { 
    $installer = Get-ChildItem "$srcDirectory\App.Test*\Add-AppDevPackage.ps1" | Select-Object -ExpandProperty FullName   
    &($installer)    
} 

$srcDirectory = "$($env:TEMP)/TestApp" 
    installApp($srcDirectory) 
} 

Remove-PSSession $newSession 

Về cơ bản, tất cả những gì bạn cần làm là chạy tập lệnh được tạo trong phòng thu trực quan để cài đặt ứng dụng. Nhưng khi tôi chạy nó tôi nhận được như sau:

Installing app... 

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF6, Det gick inte att registrera paketet. 

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

NOTE: For additional information, look for [ActivityId] a3f9b89b-3292-000113ea-f9a39232d101 in the Event Log or use the command line Get-AppxLog -ActivityID a3f9b89b-3292-0001-13ea-f9a39232d101 

At C:\Users\abc\AppData\Local\Temp\App\TestApp_1_0_0\Add-AppDevPackage.ps 1:392 char:13 
+    Add-AppxPackage -Path $DeveloperPackagePath.FullName - 
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+ CategoryInfo   :  (C:\Users\abc..._arm.appxbundle:String) [Add-AppxPackage], IOException 
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand 

Error: Could not install the app. 

Và đầu ra từ Get-AppxLog -ActivityID a3f9b89b-3292-0001-13ea-f9a39232d101 là:

Time      ID   Message                               
----      --   -------                               
2015-12-10 10:45:39  301   The calling process is wsmprovhost.exe                       
2015-12-10 10:45:39  603   Started deployment Add operation on a package with main parameter: Test.App_1.1.1.0_x86_x64_arm.appxbundle and Options: Fo 
             rceApplicationShutdownOption. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.  
2015-12-10 10:45:40  164   The app bundle signature was validated for core content of the app bundle published by CN=xxx. App packages won't be validated 
             until they are read.                            
2015-12-10 10:45:40  391   The bundle streaming reader was created successfully for bundle 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_neutra 
             l_~_m042xdac27ax6.                            
2015-12-10 10:45:40  10002  Creating Resiliency File C:\ProgramData\Microsoft\Windows\AppRepository\d195e8d8-35c4-4b85-bb4f-d99c525791c1_S-1-5-21-3220428687- 
             2095128414-3811769907-1077_1.rslc for Add Operation on Package 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_neutral 
             _~_m042xdac27ax6.                             
2015-12-10 10:45:40  607   Deployment Add operation on package 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_neutral_~_m042xdac27ax6 has been d 
             e-queued and is running for user XYZ\abc.                  
2015-12-10 10:45:40  613   Adding uri to the list of Uris: file:///C:/Users/abc/AppData/Local/Temp/TestApp/Test.App_1 
             .1.1.0_Test/Test.App_1.1.1.0_x86_x64_arm.appxbundle.                  
2015-12-10 10:45:40  614   Bundle Uri file:///C:/Users/abc/AppData/Local/Temp/TestApp/Test.App_1.1.1.0_Test/Artologik 
             .Kiosk_1.1.1.0_x86_x64_arm.appxbundle contains packages: "Test.App_1.1.1.0_x86.appx": 588388d0-5c5f-41e1-8965-f8ed6a2644.TestApp 
             _1.1.1.0_x86__m042xdac27ax6 "Test.App_1.1.1.0_x64.appx": 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_ 
             1.1.1.0_x64__m042xdac27ax6 "Test.App_1.1.1.0_ARM.appx": 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_arm__m0 
             42xdac27ax6.                              
2015-12-10 10:45:40  157   The app package signature was validated for core content of the app package published by CN=xxx. Payload won't be validated unt 
             il the files are read.                           
2015-12-10 10:45:40  170   The streaming reader was created successfully for app package 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_x86__m04 
             2xdac27ax6.                              
2015-12-10 10:45:40  613   Adding uri to the list of Uris: file:///C:/Users/abc/AppData/Local/Temp/TestApp/Test.App_1 
             .1.1.0_Test/Test.App_1.1.1.0_x86_x64_arm.appxbundle\Test.App_1.1.1.0_x86.appx.          
2015-12-10 10:45:41  446   GetFullyQualifiedReference from the Main Resource Map for package full name: 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1 
             .1.1.0_x86__m042xdac27ax6 and reference string: Test.App failed.               
2015-12-10 10:45:41  446   GetFullyQualifiedReference from the Main Resource Map for package full name: 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1 
             .1.1.0_x86__m042xdac27ax6 and reference string: xxx failed.                  
2015-12-10 10:45:41  446   GetFullyQualifiedReference from the Main Resource Map for package full name: 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1 
             .1.1.0_x86__m042xdac27ax6 and reference string: Test.App failed.               
2015-12-10 10:45:41  446   GetFullyQualifiedReference from the Main Resource Map for package full name: 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1 
             .1.1.0_x86__m042xdac27ax6 and reference string: Test.App failed.               
2015-12-10 10:45:41  446   GetFullyQualifiedReference from the Main Resource Map for package full name: 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1 
             .1.1.0_x86__m042xdac27ax6 and reference string: default.html failed.                
2015-12-10 10:45:42  10000  About to service package 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_x86__m042xdac27ax6. Setting the package state 
             to disabled returned with 0x80070490.                       
2015-12-10 10:45:42  827   Capability parsing started for the package 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_x86__m042xdac27ax6   
2015-12-10 10:45:42  5060   error 0x80070005: Adding a tile failed with unexpected error.                  
2015-12-10 10:45:42  303   error 0x80070005: While preparing to process the request, the system failed to register the windows.visualElements extension due 
             to the following error: Access is denied.                       
             .                                 
2015-12-10 10:45:42  300   error 0x80070005: Cannot register the 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_m042xdac27ax6 package due to the followi 
             ng error: Access is denied.                           
             .                                 
2015-12-10 10:45:42  605   The last successful state reached was ResolvedDeferredRegistrations. Failure occurred before reaching the next state Registration 
             Changed.                               
2015-12-10 10:45:42  472   Moving package folder \\?\C:\Program Files\WindowsApps\588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_neutral_~_m042x 
             dac27ax6 to \\?\C:\Program Files\WindowsApps\Deleted\588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_neutral_~_m042xda 
             c27ax67380de84-c8fa-4c14-a532-e6f2a1242a48. Result: 0x0.                   
2015-12-10 10:45:42  472   Moving package folder \\?\C:\Program Files\WindowsApps\588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_x86__m042xdac27 
             ax6 to \\?\C:\Program Files\WindowsApps\Deleted\588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_x86__m042xdac27ax60605 
             8072-2034-461b-a9ba-a085b10152a7. Result: 0x0.                     
2015-12-10 10:45:42  10001  Finished servicing package 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_x86__m042xdac27ax6. Setting the package sta 
             te to enabled returned with 0x0.                         
2015-12-10 10:45:42  401   Deployment Add operation with target volume C: on Package 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_neutral_~_m0 
             42xdac27ax6 from: (Test.App_1.1.1.0_x86_x64_arm.appxbundle) failed with error 0x80073CF6. See http://go.microsoft.com/fw 
             link/?LinkId=235160 for help diagnosing app deployment issues.                 
2015-12-10 10:45:42  404   AppX Deployment operation failed for package 588388d0-5c5f-41e1-8965-f8ed6a2644.Test.App_1.1.1.0_neutral_~_m042xdac27ax6 w 
             ith error 0x80073CF6. The specific error text for this failure is: error 0x80070005: Adding a tile failed with unexpected error. 

Bất kỳ sự giúp đỡ nào cả thực sự được đánh giá cao. Ý tôi là! Bất kỳ đề xuất nào, đề xuất, giải pháp, nghi lễ ngoại giáo, tinh thể, ...

+0

Bạn nhận được lỗi 'Truy cập bị từ chối' tại điểm lỗi đầu tiên. Người dùng cục bộ, người đã đăng nhập và đang chạy tập lệnh, có toàn quyền để cài đặt các ứng dụng trên hệ thống không? tức là: Không phải người dùng bị hạn chế/địa phương? – gravity

+0

Trong trường hợp của tôi, tài khoản tôi đang sử dụng có quyền quản trị viên. Tôi đã thử bằng cách sử dụng ProcMon để xem nơi truy cập bị từ chối lỗi đã đến từ, nhưng tất cả tôi có thể thấy được truy vấn cho một số khóa registry mà tài khoản có quyền kiểm soát đầy đủ quyền truy cập vào. – Shoaib

Trả lời

2

Tôi đã chạy vào cùng một lỗi chính xác. Tôi đã cố gắng để cài đặt trên Cygwin SSH thay vì Powershell remoting, nhưng tôi nghi ngờ nguyên nhân gốc là tương tự.

Tôi đã có thể giải quyết vấn đề này bằng cách thiết lập tác vụ được lên lịch chạy tập lệnh Powershell tại một vị trí nổi tiếng. Tôi có thể từ xa thiết lập nội dung của tập lệnh Powershell này để chạy kịch bản cài đặt ứng dụng, và sau đó khởi chạy tác vụ theo lịch trình bằng cách sử dụng schtasks, hoạt động như một sự quyến rũ.

+0

Tôi không phải là OP nhưng tôi đã thực hiện tiền thưởng và những gì bạn đề xuất đã làm việc –

0

Vì vậy, đúng vậy, như Shoaib đã chỉ ra, nhiệm vụ được lên lịch sẽ thực hiện thủ thuật. Bạn cũng có thể thử bắt đầu quá trình từ xa thông qua WMI như vậy:

Invoke-WmiMethod -Class win32_process -name Create -ComputerName dflt -Credential $cred -ArgumentList "powershell.exe -noprofile -noninteractive -executionpolicy bypass -encodedCommand 'your encoded command goes here'" 

Bạn cũng có thể thử tung ra một quá trình PowerShell từ bên trong phiên ps (cung cấp khác sử dụng thông tin) và đi qua lệnh để quá trình đó (khá giống với phương pháp WMI , nhưng từ PSSession).

Bạn đã thử gọi lệnh trên máy từ xa chưa? mà có thể làm việc (althou tôi nghi ngờ nó).

Bạn có thể sử dụng Cấu hình trạng thái mong muốn để đạt được những gì bạn cần, nhưng đó là một chút quá mức cần thiết (nhưng phải hoạt động 101%). Có nghĩa vụ phải là một nhà cung cấp kịch bản cho DSC.

0

Tôi bị kẹt chính xác trong cùng một vấn đề trong vài ngày. Sau khi tìm thấy chủ đề này và đọc câu trả lời của Shoaib, tôi bắt đầu chơi với các tác vụ đã lên lịch và cuối cùng viết một kịch bản làm việc cho tôi. Tôi tìm thấy rất nhiều vấn đề với nhiệm vụ và Add-AppxPackage và nhận ra rằng bạn phải cấu hình nhiệm vụ với tùy chọn "Người dùng phải đăng nhập" (xin lỗi, phiên bản tiếng Tây Ban Nha). Add-AppxPackage cần người dùng phải đăng nhập vào Tác phẩm, có thể giải thích tại sao không hoạt động với Invoke-Command.

$adminUser = "[email protected]" 
$adminPass = "xxxxxxx" 

$pw = ConvertTo-SecureString -AsPlainText -Force -String $adminPass 
$cred = New-Object -Typename System.Management.Automation.PSCredential -ArgumentList $adminUser, $pw 

$command = "Add-AppxPackage -Path '\\path\App.appxbundle'" 
$bytes = [Text.Encoding]::Unicode.GetBytes($command) 
$encodedCommand = [Convert]::ToBase64String($bytes) 

$remoteUser = "[email protected]" 
$remoteComputer = "192.168.0.50" 

$taskName = "Task" 
$taskCommand = "powershell.exe" 
$taskArg = "-noprofile -noninteractive -windowstyle hidden -executionpolicy bypass -encodedCommand ""$encodedCommand""" 

$taskAction = New-ScheduledTaskAction -Execute $taskCommand -Argument $TaskArg 
$taskTrigger = New-ScheduledTaskTrigger -At 9am -Once 
$taskPrincipal = New-ScheduledTaskPrincipal -UserID $remoteUser -LogonType Interactive -RunLevel Highest 

$cimSession = New-CimSession -ComputerName $remoteComputer -Credential $cred -Authentication Negotiate 

Register-ScheduledTask -Action $taskAction -Trigger $tasktrigger -TaskName $taskName -Principal $taskPrincipal -CimSession $cimSession 

Start-ScheduledTask -CimSession $cimSession -TaskName $taskName 

Sleep 5 

Get-ScheduledTask -CimSession $cimSession | Where-Object {$_.TaskName -eq $taskName} | Unregister-ScheduledTask -CimSession $cimSession -Confirm:$false 
Các vấn đề liên quan