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

标签 powershell powershell-3.0

PowerShell控制台和PowerShell ISE有什么区别。我在PowerShell中的配置文件上下文中问这个问题。因为PowerShell控制台和PowerShell ISE都有不同的网络配置文件。

最佳答案

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控制台和PowerShell ISE之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20022976/

相关文章:

iis - 如何使用Powershell脚本执行IISRESET

maven - 函数参数名称中的点

powershell - 改进代码以在 PowerShell 中使用可选开关参数

Powershell 3克隆一个对象有意外的结果 - 影响其他对象

powershell - 使用 Invoke-WebRequest 以及用户名和密码在 GitHub API 上进行基本身份验证

powershell - 从管道构建 Powershell 字符串参数

powershell - out-file 问题(空管元素)

powershell-3.0 - 到远程服务器的 Enter-PSSession 失败并显示 "cannot find the computer"

powershell - 抑制导入模块的 VERBOSE

json - 如何使用 Powershell 将 JSON 对象保存到文件中?