PowerShell控制台和PowerShell ISE的区别是什么?我在PowerShell配置文件的上下文中提出这个问题。因为PowerShell控制台和PowerShell ISE都有不同的配置文件。
PowerShell控制台和PowerShell ISE的区别是什么?我在PowerShell配置文件的上下文中提出这个问题。因为PowerShell控制台和PowerShell ISE都有不同的配置文件。
交互式控制台应用程序支持有限,尝试使用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
控制台应用程序输出不带颜色
默认为STA
a) 尝试 $host.Runspace.ApartmentState
b) PowerShell默认为MTA(ApartmentState显示为Unknown),但可以使用powershell -sta启动为sta模式。
c) ISE始终为STA
不支持[Console]类,尝试[console] :: BackgroundColor ='white'。
a) 一般而言,脚本应使用主机API(例如write-host)而不是[Console]类,以便它们适用于控制台、ISE、远程和其他shell。
$host.UI.RawUI的支持极其有限(接近零)。我们只支持颜色和标题
a) 最好在$psISE.Options中设置颜色,因为您可以将其设置为任何颜色,而不仅仅是控制台颜色
自定义/简单翻页。请参阅gc函数:more
a) ISE没有分页器
Start-Transcript在ISE中无效
一些线程区域差异
a) 如果您所在的地区不支持控制台(例如阿拉伯文),则ISE将获取ar-sa作为Get-Culture,而powershell.exe将fallback为en-us或其他值。
建议在ISE中无效
a) 例如,在"C:\Program Files\Internet Explorer"中执行iexplore.exe
b) 只有在PowerShell.exe中才会看到以下建议[3,常规]:找不到命令iexplore.exe,但当前位置确实存在。默认情况下,Windows PowerShell不会从当前位置加载命令。如果您信任此命令,请输入“. \ iexplore.exe”。
有关更多详细信息,请参见“get-help about_Command_Precedence”。
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中运行
只有ISE具有$psISE
a)it可以访问http://psisecream.codeplex.com/和http://blogs.msdn.com/powershell/archive/2008/12/29/powershell-ise-can-do-a-lot-more-than-you-think.aspx
$profile | fl -Force
。 - Keith Hill