从PowerShell ISE的命令环境加载脚本

时间:2015-06-03 16:59:24

标签: powershell powershell-v3.0 powershell-ise

有没有办法在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

1 个答案:

答案 0 :(得分:3)

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

PS> ise myscript.ps1

要使Invoke-Item的行为与您想要的一样(以及从资源管理器中双击),您可以将.ps1文件与powershell_ise.exe相关联。如果您需要,可以参考博文explaining how to do this

相关问题