Skip to content

Wait-Logging Hanging Scheduled Task #124

@krocd

Description

@krocd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions