This is an old question now, but I came here looking for an answer so figured I'd give the results of my experimentation.
There is a $psISE
object which controls ISE settings, the open files, etc. There is a lot you can do with it.
There was a promising looking function:
$psISE.CurrentPowerShellTab.Files.Clear()
Unfortunately, this would simply close all open files (if they were saved) and then open a new untitled file.
I ended up with this:
$null = while ($psISE.CurrentPowerShellTab.Files -ne $null) { $file = $psISE.CurrentPowerShellTab.Files[0] $psISE.CurrentPowerShellTab.Files.Remove($file) }
Basically, it keeps checking the open files, and closes them until there are none left open. If you were to run this interactively, and had an unsaved document open, you'd be flooded by error pretty quickly as it fails to close then loops back to trying to close it again.
You can then put this in your ISE profile (C:\username\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1). This is what my profile looks like at the moment:
$null = while ($psISE.CurrentPowerShellTab.Files -ne $null) { $file = $psISE.CurrentPowerShellTab.Files[0] $psISE.CurrentPowerShellTab.Files.Remove($file) } psEdit $PSScriptRoot\snips.ps1
Since this runs when launching the ISE, it closes the default untitled file and opens a random file with little snippets I like to refer to instead. You could omit that last line or change it to any file you want to open.
n.b. that $null =
is in there to suppress output, and it is faster than piping to Out-Null
(which I think is important when you're waiting for your editor to load.)