Invoke-CommandAs icon indicating copy to clipboard operation
Invoke-CommandAs copied to clipboard

Interactive Execution as SYSTEM Fails to Launch in Visible Session

Open aollivierre opened this issue 1 year ago • 1 comments

Title: Interactive Execution as SYSTEM Fails to Launch in Visible Session

Description: When attempting to run a script interactively as SYSTEM using Invoke-CommandAs, the task fails to run in a visible interactive session. Despite using the -AsInteractive parameter with 'SYSTEM', the script executes in the background and is not presented interactively on the desktop.

Steps to Reproduce:

  1. Import the Invoke-CommandAs module.

  2. Attempt to run a PowerShell script interactively as SYSTEM:

    Invoke-CommandAs -ScriptBlock {
        & "C:\path\to\script.ps1"
    } -AsInteractive 'SYSTEM'
    
  3. Observe that the script runs but is not visible in the interactive session.

Expected Behavior: The script should execute interactively, allowing user interaction with the console window or any UI components presented by the script.

Actual Behavior: The script runs in the background, with no interactive session presented on the desktop.

Environment Details:

  • OS: Windows 10/11
  • PowerShell Version: 5.1
  • Invoke-CommandAs Version: Latest (v3.1.9)
  • Script: Any PowerShell script (e.g., a PSAppDeployToolkit script or a basic console interaction)

Additional Context:

  • Running the same script manually or using other interactive SYSTEM methods (e.g., via Task Scheduler with "Allow interaction with desktop") works as expected.
  • I also attempted using -AsSystem and -AsUser, but only -AsInteractive 'SYSTEM' seems to fail to launch in an interactive session.

Please let me know if there are any additional flags or methods to ensure interactive execution as SYSTEM, or if this could be a potential bug with the module.


Let me know if you'd like any changes before submitting it!

aollivierre avatar Sep 05 '24 17:09 aollivierre

Are you able to replicate the interactive SYSTEM method using powershell manually?

mkellerman avatar Sep 22 '24 15:09 mkellerman

Closed due to inactivity

mkellerman avatar Dec 31 '24 19:12 mkellerman