craig
craig

Reputation: 26262

Load script from PowerShell ISE's command environment

Is there a way to open a script file ($profile or otherwise) from within the IDE's command environment (PS> prompt), such that it loads in the IDE itself?

# 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

Upvotes: 2

Views: 452

Answers (1)

Ryan Bemrose
Ryan Bemrose

Reputation: 9266

Instead of Invoke-Item, just use ise. When run from the ISE, it will load the file.

PS> ise myscript.ps1

To make Invoke-Item behave like you want (as well as double-clicking from Explorer), you can associate .ps1 files with powershell_ise.exe. Here is a blog post explaining how to do this if you need it.

Upvotes: 3

Related Questions