如何将powershell“pwsh”更改为STA ApartmentState

时间:2018-03-14 08:37:46

标签: powershell sta mta powershell-v6.0

我正在尝试将一些脚本从poweshell 5.0移植到新的pwsh powershell 6,我注意到不再有-sta参数了。如何设置pwsh的ApartmentState?我无法找到任何关于它的内容,看起来它在编译时被定义为mta或sta,具体取决于目标平台。我是对的吗?

C:\WINDOWS\system32>pwsh -sta
The argument '-sta' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

C:\WINDOWS\system32>powershell -sta
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

1 个答案:

答案 0 :(得分:0)

由于...核心组件旨在跨多个平台工作,因此我认为您将发现不包含Windows特定概念。如果您需要跨平台兼容性,则需要寻找另一种方法。如果您不使用Powershell并意识到随着pwsh的发展,它将逐渐落后于可用功能。

相关问题