【问题标题】:Load script from PowerShell ISE's command environment从 PowerShell ISE 的命令环境加载脚本
【发布时间】:2015-06-03 16:59:23
【问题描述】:

有没有办法从 IDE 的命令环境(PS> 提示符)中打开脚本文件($profile 或其他),以便它在 IDE 本身中加载?

# loads the current user/current host profile in Notepad (probably because .PS1 is associated w/ Notepad.exe)
PS > ii $profile

# same for any random script file
PS > ii .\Foo.ps1

【问题讨论】:

  • 我将 .ps1 文件的“打开方式”属性更改为 powershell ise。然后“ii $profile”将在 ise 中打开我的个人资料。

标签: powershell powershell-3.0 powershell-ise


【解决方案1】:

不要使用Invoke-Item,而是使用ise。从 ISE 运行时,它将加载文件。

PS> ise myscript.ps1

要使 Invoke-Item 的行为符合您的要求(以及从资源管理器中双击),您可以将 .ps1 文件与 powershell_ise.exe 关联。如果您需要,这里有一篇博文explaining how to do this

【讨论】:

  • 在此期间(等待答复),我决定使用该别名为 IDE 创建一个别名,但发现它已经存在。
  • 如果多个 ISE 打开,ise 命令似乎会随机选择一个 ISE。您会认为它会选择执行命令的 ISE。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-16
  • 2011-10-12
相关资源
最近更新 更多