Invoke-CommandInDesktopPackage ( Not able to execute Invoke-CommandInDesktopPackage with Ansible (win_shell) option

Hi Team,

I am not able to execute Invoke-CommandInDesktopPackage with Ansible (win_shell) , facing below error. please check and let me how to fix the issue.
I am running with Full access User.

Invoke-CommandInDesktopPackage : System.UnauthorizedAccessException occurred when attempting to \r\ninvoke the provided command in desktop package.
Run Invoke-CommandInDesktopPackage -? for usage \r\ndetails. Additional detail: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))\r\nAt C:\launch.ps1:16 char:6\r\n+ Invoke-CommandInDesktopPackage "cmd" -Args $executable -PackageF …\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (:slight_smile: [Invoke-CommandInDesktopPackage], UnauthorizedAcce \r\n ssException\r\n + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Windows.Appx.PackageCom \r\n mands.InvokeCommandInDesktopPackage\r\n \r\nStop-Process : Cannot stop process "cmd (424)" because of the following error: Windows PowerShell \r\nis in NonInteractive mode. Read and Prompt functionality is not available.\r\nAt C:\launch.ps1:19 char:6\r\n+ Stop-Process -Name CMD\r\n+ ~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : CloseError: (System.Diagnostics.Process (cmd):Process) [Stop-Process \r\n ], ProcessCommandException\r\n + FullyQualifiedErrorId : CouldNotStopProcess,Microsoft.PowerShell.Commands.StopProcessCommand",

Even windows to windows execution, it is giving below error, does Invoke-CommandInDesktopPackage don’t work through remote execution.

Invoke-CommandInDesktopPackage : A specified logon session does not exist. It may already have been terminated. \r\n(Exception from HRESULT: 0x80070520)\r\nAt line:10 char:1\r\n+ Invoke-CommandInDesktopPackage "cmd" -Args $executable -PackageFamily …\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (:slight_smile: [Invoke-CommandInDesktopPackage], COMException\r\n + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.Windows.Appx.PackageCommands.Invok \r\n eCommandInDesktopPackage

Try using Ansible become to workaround this problem. It isn’t a guarantee but it acts like the process was executed on an interactive logon. You could have trouble if the command is expecting user input. This can’t be done on Ansible.