locked
how can i tell if a script is running or hung RRS feed

  • Question

  • I am running this script. How can I tell if is actually running or hung?

    import-module activedirectory

    $logName= "security"

    $pcName= "cbsdcs223"

    $eventID= "4740"

    Get-EventLog -LogName $logName -ComputerName $pcName | where {$_.eventID -eq $eventID} `

    |fl -Property timegenerated, replacementstrings, message


    Thursday, April 26, 2018 1:54 PM

Answers

All replies

  • Not what exactly you are looking for .Hope this may help you

    https://blogs.msdn.microsoft.com/wushuai/2017/01/20/figure-out-the-line-of-code-when-powershell-hang/

    Thursday, April 26, 2018 2:17 PM
  • I don't think there is anyway of checking to see if a script has hung.

    You could use a timer to automatically stop the script after a certain amount of time just in case the script does hand. or use PowerShell jobs to get the status of the job?

    Job Examples


    Learn PowerShell                     Script Requests

    -Remember to mark the correct response as the answer-

    Thursday, April 26, 2018 3:22 PM
  • One simple method is to start a transcript and look at it after the script has been killed.


    \_(ツ)_/

    Thursday, April 26, 2018 6:50 PM