-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wait-Logging Hanging Scheduled Task #124
Comments
I was wrong, it's not Wait-Logging that is blocking the process exit. It's something else. I was able to reproduce it outside of Task Scheduler by simply executing the same script at the command line (recall that the script imports a custom module, that imports the Logging module and wraps its functions):
The command prompt simply hangs waiting on the spawned powershell.exe process to end; which it never does. I even tried adding a |
The issue seems to be in the OnRemoval event handler. For some reason, the call to |
I've seen similar and I chalked it up to where on the filesystem I was having the SYSTEM principal try to do Import-Module. I had different results with it in the System32\windowsPowershell\1.0\modules folder vs when used elsewhere too. Hope you figure it out! |
I'm trying to debug why a Windows Scheduled Task is hanging at Wait-Logging, even though all other operations have completed and I see all of the expected log entries flushed to the log file.
The logging target is a file.
The design is:
Custom PS script module containing wrapper functions for Add-LoggingTarget, Write-Log, and Wait-Logging. These wrappers are used to set/force certain defaults for our environment and ensure consistent use of logging based on our standards.
Script uses custom script module functions to start logging (wrapper for Add-LoggingTarget), write log messages (wrapper for Write-Log), and to stop logging (wrapper for Wait-Logging).
When the script is executed by Windows Task Scheduler, execution hangs at the wrapper function called to stop logging (Wait-Logging). I see all expected messages in the log file, however it seems that the call to Wait-Logging is simply hanging until the Task Scheduler times out the task and kills it.
Is Wait-Logging or the LoggingEventQueue affected by the CallerScope? The documentation isn't really clear on exactly where the caller scope is referenced and what all it affects.
The text was updated successfully, but these errors were encountered: