How do I prevent Powershell from closing after completion of a script?

前端 未结 2 1271
灰色年华
灰色年华 2021-01-14 08:47

Disclaimer : I am the epitome of a scipting/Powershell rookie, so please bear with me.

I\'ve written a script to return the Active Directory username of any

2条回答
  •  终归单人心
    2021-01-14 09:32

    I had the same problem for scripts that I'm executing "on demand". I tend to simply add a Read-Host at the end of the script like so

    $str = "This text is hardly readable because the console closes instantly" 
    Write-Output $str
    
    Read-Host "Script paused - press [ENTER] to exit"
    

提交回复
热议问题