PowerShell 控制台和 PowerShell ISE 之间的区别 [英] Difference between PowerShell Console and PowerShell ISE

查看:93
本文介绍了PowerShell 控制台和 PowerShell ISE 之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

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

<块引用>

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

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

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

  3. 默认 STA

    a) 试试 $host.Runspace.ApartmentState

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

    c) ISE 始终是 STA

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

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

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

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

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

    a) ISE 没有寻呼机

  7. Start-Transcript 在 ISE 中不起作用

  8. 一些线程文化差异

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

  9. 建议在 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".

  10. ISE 运行不同的配置文件

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

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

    c)http://www.leeholmes.com/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx

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

  11. 只有 ISE 有 $psISE

    a) 它可以访问 http://psisecream.codeplex.com/http://blogs.msdn.com/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:-

  1. 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 http://blogs.msdn.com/powershell/archive/2009/02/04/console-application-non-support-in-the-ise.aspx

  2. Console Application output is not colorful

  3. 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

  4. 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.

  5. 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

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

    a) The ISE has no pager

  7. Start-Transcript does not work in the ISE

  8. 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)

  9. 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.

  10. 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) http://msdn.microsoft.com/en-us/library/bb613488(VS.85).aspx

    c) http://www.leeholmes.com/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx

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

  11. Only the ISE has $psISE

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

这篇关于PowerShell 控制台和 PowerShell ISE 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆