Save All PowerShell ISE files

PowerShell Team

PowerShell ISE is a simple tool and in some cases it has the bare essentials. For instance, it does not have an option to save all files.

On the flipside, it offers an Object Model from its first version that allows adding features beyond the essentials like this one and many more. 

If we had the “Save All” option in the ISE, one interesting question is what to do about untitled files. They are supposed to be transient. One could argue that Save All could just skip untitled files. Another could argue that we should just pick a name for untitled, but I would disagree with “another” 🙂 Picking a name would soon fill some place in disk (which we would also have to pick) with a bunch of untitled files, which were supposed to be transient in the first place. We could prompt the user to pick a name for the untitled files, or show where we save them like we do in the PowerShell exit, but that doesn’t look like the very autonomous Save All in other applications.

The code below should be self explanatory and it skips untitled files as I thought better.

If you like it, you can add it to your profile (psedit $profile will edit the ISE profile) or to a module imported in your profile.

Lucio Silveira [MSFT]

function Save-AllISEFiles




    Saves all ISE Files except for untitled files. If You have       multiple PowerShellTabs, saves files in all tabs.


    foreach($tab in $psISE.PowerShellTabs)


        foreach($file in $tab.Files)










# This line will add a new option in the Add-ons menu to save all ISE files with the Ctrl+Shift+S shortcut.

# If you try to run it a second time it will complain that Ctrl+Shift+S is already in use

$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(“Save All”,{Save-AllISEFiles},“Ctrl+Shift+S”)





Comments are closed. Login to edit/delete your existing comments