Win7 need for -STA

Apr 29, 2009 at 9:14 PM
I thought the need for -STA mode was gone with the newest release of PowerBoots, but if I try to in -MTA mode, Powerboots will not load complaining about -STA.

Here is the error that shows on the console:

 

Windows PowerShell V2
Copyright (C) 2008 Microsoft Corporation. All rights reserved.

WARNING: You must run PowerShell with the -STA switch in order to use PowerBoots ConsoleHost is running in MTA mode.
At C:\Users\millerj\Documents\WindowsPowerShell\Modules\PowerBoots\PowerBoots.psm1:80 char:9
+    throw <<<<  "$($Host.Name) is running in MTA mode."
    + CategoryInfo          : OperationStopped: (ConsoleHost is running in MTA mode.:String) [], RuntimeException
    + FullyQualifiedErrorId : ConsoleHost is running in MTA mode.

Import-Module : The module to process 'PowerBoots', listed in module manifest 'C:\Users\millerj\Documents\WindowsPowerS
hell\Modules\PowerBoots\PowerBoots.psd1' was not processed because no valid module was found in any module directory.
At C:\Users\millerj\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:4 char:14
+ Import-Module <<<<  PowerBoots
    + CategoryInfo          : ResourceUnavailable: (PowerBoots:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

Can someone shed some light on this for me?

Thanks,
Jeff

Coordinator
Apr 30, 2009 at 3:33 AM
Yeah, that's an error in the script, sorry -- it's fixed in source control, and I'm pushing a new release in the next few hours...
--
Joel

SithRee wrote:

From: SithRee

I thought the need for -STA mode was gone with the newest release of PowerBoots, but if I try to in -MTA mode, Powerboots will not load complaining about -STA.
May 22, 2014 at 4:00 PM
Still occurs on Windows 7 with installed build 2.0.50727.4963
(Im not getting correct version info for the core dll I'm sure, but that's my best guess at version number for now.) Not using powerboots.
Coordinator
May 22, 2014 at 4:07 PM
What are you using?

Windows doesn't allow User Interfaces from MTA applications. That's why in PowerShell 3, Microsoft changed PowerShell to run -STA by default and added the -MTA switch.

With ShowUI, if you want to do UI in PowerShell 2 without running PowerShell with the -STA switch, you have to use -AsJob to get a new thread.
May 23, 2014 at 8:13 AM
OK, its not an issue then :) I'm running the 2.0 host. My intent is to run this on server 2008/R2 or higher, so Posh3 just needs to be installed first, or I can use -STA :)
Thanks for explaining the mode switch.