Skip to main content

Helper function for semi-structured (verbose) logging, to manage verbose output of the other functions.

function Write-VerboseOutput
{
    <#
    .SYNOPSIS
        Helper function for semi-structured logging, to manage verbose output of the other functions.
    #>
    [CmdletBinding()]
    param(
        [Parameter(Position = 0, Mandatory)]
        [String]$Message
    )

    $TimeStamp = Get-Date -Format s # e.g. '2022-10-04T03:11:59'
    $CallingCommand = (Get-PSCallStack)[1].Command
    $MessageData = '{0} [{1}] : {2}' -f $TimeStamp, $CallingCommand, $Message

    Write-Verbose -Message $MessageData
}