All PowerShell versions
To preserve all the PowerShell commands that you entered in a PowerShell session, check out this one liner:
(Get-History).CommandLine | clip.exe
It copies all commands to the clipboard. From there, you can paste them into PowerShell ISE and save them.