# How can I open a ps1 script in Powershell ISE from the command line?

Tag: powershell Author: dianjing200336 Date: 2009-08-10

I'm trying to figure out how I can open a ps1 script (or any file) in PS ISE by using the \$psISE object.

How can I open a document tab in PS ISE from the command line in PS ISE itself (without using File > Open)?

 Wow, I can't believe someone is as much a stickler as me to have asked this one before. Kudos!

psEdit filename

 both solutions work, but this is the easiest. Thank!

PowerShell 2.0 in Windows 7, PSEdit does not work. Use "ise", which is an alias for `powershell_ise.exe`.

``````ex. ise .\myscript.ps1
``````

 +1. I could use the ex. portion (new to PS) +1 When working in the standard PS console, this is the way to open a file in the ISE.

 Programmatically, this works: ``````\$psISE.CurrentPowerShellTab.Files.Add("\$pwd\foo.ps1") `````` Which is essentially what the PSEdit function uses. To see this execute: ``````Get-Command PSEdit | Format-List * ``````
 I took the psedit command and allowed input from the pipeline ``````Function psedit { param( [Parameter(Mandatory=\$true,ValueFromPipeline=\$true)]\$filenames) foreach (\$filename in \$filenames) { dir \$filename | where {!\$_.PSIsContainer} | %{ \$psISE.CurrentPowerShellTab.Files.Add(\$_.FullName) > \$null } } } `````` This allows me to something like this ``````7 > ls test*.ps1 | psedit `````` I find this useful when working on modules and I have several scripts in a directory Andy