Open PowerShell first, then run your script from that existing session. The prompt normally returns after the script finishes. A window launched just to run one script can close when that PowerShell process ends.
Keep a newly launched session open
For PowerShell 7, use:
pwsh -NoExit -File "C:\Scripts\Report.ps1"For Windows PowerShell 5.1, use:
powershell.exe -NoExit -File "C:\Scripts\Report.ps1"Replace the example path with your script. Place -NoExit before -File. An explicit exit inside the script can still end the process.
Run inside an existing session
.\Report.ps1The .\ prefix means the current folder. For a quoted full path, use the call operator:
& "C:\My Scripts\Report.ps1"If PowerShell cannot find the command, check command discovery and script paths. If it reports that scripts are disabled, see execution policy scopes.
Pause only when interaction is intended
Read-Host "Press Enter to continue"You can place this at the end of a script intended for a person at a terminal. It can block unattended jobs. Start-Transcript records session output; it does not itself prevent a window from closing. Keep the terminal open while diagnosing errors instead of relying on a transcript to control its lifetime.
Sources and verification
Command syntax checked against Microsoft documentation. Windows terminal launch behavior was not executed on Windows for this revision.
