< Back

Wait-PSFMessage

Sun Jan 19, 2020 6:46 pm

NAME Wait-PSFMessage



SYNOPSIS

Waits until the PSFramework log queue has been flushed.





SYNTAX

Wait-PSFMessage [[-Timeout] <DateTimeParameter>] [-Terminate] [<CommonParameters>]





DESCRIPTION

Waits until the PSFramework log queue has been flushed.

Also supports ending the logging runspace.



This is designed to explicitly handle script termination for tasks that run in custom hosts that do not properly

fire runspace termination events, leading to infinitely hanging tasks.





PARAMETERS

-Timeout <DateTimeParameter>

Maximum duration for the command to wait until it terminates even if there are messages left.



Required? false

Position? 1

Default value 5m

Accept pipeline input? false

Accept wildcard characters? false



-Terminate [<SwitchParameter>]

If this parameter is specified it will terminate the running logging runspace.

Use this if your script will run in a powershell host that does not properly execute termination events.

Danger!!!! Should never be used in a script that might be called by other scripts, as this might prematurely

end logging!



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Wait-PSFMessage



Waits until all pending messages are logged.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Wait-PSFMessage -Timeout 1m -Terminate



Waits up to one minute for all messages to be flushed, then terminates the logging runspace











RELATED LINKS