ironmansoftware / powershell-pro-tools

Scripting, automation, and development tools for professionals working with PowerShell.
MIT License
62 stars 3 forks source link

-Confirm flag doesn't work in Visual Studio #23

Open adamdriscoll opened 2 years ago

adamdriscoll commented 2 years ago

Describe the bug

Attempting to run Stop-Process with confirm results in an error.

To Reproduce

Users\adamr\source\repos\PowerShellFormProject1> Start-Process notepad -PassThru

 NPM(K)    PM(M)      WS(M)     CPU(s)      Id  SI ProcessName
 ------    -----      -----     ------      --  -- -----------
     10     1.79       8.57       0.17   23344   4 Notepad

PS C:\Users\adamr\source\repos\PowerShellFormProject1> Stop-Process -Id 23344 -Confirm
[ERROR] 
[ERROR] Stop-Process: The calling thread must be STA, because many UI components require this.

PS C:\Users\adamr\source\repos\PowerShellFormProject1> Stop-Process -Id 23344 

PS C:\Users\adamr\source\repos\PowerShellFormProject1> 

Expected behavior

Confirm should perform the confirm action.

Version

Tool (Visual Studio, VS Code, PSScriptPad, PS Module): VIsual Studio Version Number: 2021.12.2 Operating System: Win11

adamdriscoll commented 2 years ago

This issue has been mentioned on Ironman Software Forums. There might be relevant details there:

https://forums.ironmansoftware.com/t/the-calling-thread-must-be-sta-because-many-ui-components-require-this-error-in-interactive-window/6369/2