PowerShell 控制台和 PowerShell ISE 之间的区别

编程入门 行业动态 更新时间:2024-10-03 02:26:43
本文介绍了PowerShell 控制台和 PowerShell ISE 之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

PowerShell 控制台和 PowerShell ISE 之间有什么区别.我是在 PowerShell 中的 Profiles 上下文中问这个问题的.因为 PowerShell 控制台和 PowerShell ISE 都有不同的配置文件.

解决方案

来自 ISE 和 PowerShell 控制台之间的差异:-

  • 对交互式控制台应用程序的支持有限,请尝试 cmd.exe,然后尝试cmd.exe/k

    a) cmd.exe/c dir 仍然有效,更多信息可在此处获得blogs.msdn/powershell/archive/2009/02/04/console-application-non-support-in-the-ise.aspx

  • 控制台应用程序输出不彩色

  • 默认 STA

    a) 试试 $host.Runspace.ApartmentState

    b) 默认情况下,powershell 是 MTA(ApartmentState 显示为未知),但可以使用 powershell -sta 以 sta 模式启动.

    c) ISE 始终是 STA

  • 不支持 [Console] 类,试试 [console]::BackgroundColor= '白色'.

    a) 通常,脚本应该使用主机 API(写主机,而不是 [Console] 类,以便它们在控制台、ISE、远程处理和其他外壳.

  • 对 $host.UI.RawUI 的支持有限(接近于零).我们只支持颜色和标题

    a) 颜色最好在 $psISE.Options 中设置,因为您可以将它们设置为任何颜色,而不仅仅是控制台颜色

  • 自定义/死简单更多.查看 gc 函数:更多

    a) ISE 没有寻呼机

  • Start-Transcript 在 ISE 中不起作用

  • 一些线程文化差异

    a) 如果您使用的是非控制台支持的文化(例如阿拉伯语),ISE 将使用 Get-Culture 作为 ar-sa,而 powershell.exe 将具有Get-Culture 作为 en-us(或其他一些后备)

  • 建议在 ISE 中不起作用

    a) 例如,如果您执行 iexplore.exe,则在 C:\Program Files\Internet Explorer 中

    b) 您只会在 PowerShell.exe 中看到此建议 [3,General]: The command iexplore.exe was not found, but does exist in the current地点.Windows PowerShell 不会从当前加载命令默认位置.如果您信任此命令,请输入.\iexplore.exe".

    有关详细信息,请参阅获取帮助 about_Command_Precedence".

  • ISE 运行不同的配置文件

    a) ISE 配置文件位于 Microsoft.PowerShellISE_profile.ps1 中,powershell 位于 Microsoft.PowerShell_profile.ps1 中

    b) msdn.microsoft/en-us/library/bb613488(VS.85).aspx

    c)www.leeholmes/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx

    d) 您可以使用存储在 $profile.CurrentUserAllHosts 中的公共配置文件使其在两个 shell 中运行

  • 只有 ISE 有 $psISE

    a) 它可以访问 psisecream.codeplex/ 和 blogs.msdn/powershell/archive/2008/12/29/powershell-ise-can-do-a-lot-more-than-you-think.aspx

  • What are differences between PowerShell Console and PowerShell ISE. I am asking this question in context of Profiles in PowerShell. Because PowerShell Console and PowerShell ISE both have differnet profiles.

    解决方案

    From Differences between the ISE and PowerShell console:-

  • Limited support for interactive console apps, try cmd.exe, then try cmd.exe /k

    a) cmd.exe /c dir still works though, and more information is available here blogs.msdn/powershell/archive/2009/02/04/console-application-non-support-in-the-ise.aspx

  • Console Application output is not colorful

  • STA by default

    a) Try $host.Runspace.ApartmentState

    b) powershell is MTA by default (ApartmentState shows up as Unknown) but can be started in sta mode with powershell -sta.

    c) ISE is always STA

  • No support for the [Console] class, try [console]::BackgroundColor = 'white'.

    a) In general, scripts should use the host API's (write-host, instead of the [Console] class, so that they work in both the console, ISE, Remoting and other shells.

  • Limited (close to zero) support on $host.UI.RawUI. We only support the colors and title

    a) The colors are better set in $psISE.Options, because you can set those to any color, not just console colors

  • Custom/dead-simple more. See gc function:more

    a) The ISE has no pager

  • Start-Transcript does not work in the ISE

  • Some Thread Culture differences

    a) If you’re in a non-console supported culture (eg Arabic) ISE will have Get-Culture as ar-sa, and powershell.exe will have Get-Culture as en-us (or some other fallback)

  • Suggestions dont work in the ISE

    a) For example, in C:\Program Files\Internet Explorer" if you execute iexplore.exe

    b) You'll only see this in PowerShell.exe Suggestion [3,General]: The command iexplore.exe was not found, but does exist in the current location. Windows PowerShe ll doesn't load commands from the current location by default. If you trust this command, instead type ".\iexplore.exe".

    See "get-help about_Command_Precedence" for more details.

  • The ISE runs a different profile

    a) The ISE profile is in Microsoft.PowerShellISE_profile.ps1, and powershell is in Microsoft.PowerShell_profile.ps1

    b) msdn.microsoft/en-us/library/bb613488(VS.85).aspx

    c) www.leeholmes/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx

    d) You can use the common profile, stored in $profile.CurrentUserAllHosts to make it run in both shells

  • Only the ISE has $psISE

    a)it gets access to psisecream.codeplex/, and blogs.msdn/powershell/archive/2008/12/29/powershell-ise-can-do-a-lot-more-than-you-think.aspx

  • 更多推荐

    PowerShell 控制台和 PowerShell ISE 之间的区别

    本文发布于:2023-11-03 04:32:49,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1554239.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:控制台   区别   PowerShell   ISE

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!