Functions/Write-VerboseLog.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<#
    .SYNOPSIS
        Log a verbose message.
 
    .DESCRIPTION
        Log a verbose message to the log file, the event log and show it on the
        current console. If the global log level is set to 'information', no
        verbose message will be logged.
 
    .INPUTS
        None.
 
    .OUTPUTS
        None.
 
    .EXAMPLE
        PS C:\> Write-VerboseLog -Message 'My Verbose Message'
        Log the verbose message.
 
    .EXAMPLE
        PS C:\> Write-VerboseLog -Name 'MyLogger' -Message 'My Verbose Message'
        Log the verbose message in a custom logger.
 
    .NOTES
        Author : Claudio Spizzi
        License : MIT License
 
    .LINK
        https://github.com/claudiospizzi/ScriptLogger
#>


function Write-VerboseLog
{
    [CmdletBinding()]
    param
    (
        # The logger name.
        [Parameter(Mandatory = $false)]
        [System.String]
        $Name = 'Default',

        # The verbose message.
        [Parameter(Mandatory=$true, Position = 0, ValueFromPipeline = $true)]
        [System.String[]]
        $Message
    )

    process
    {
        foreach ($currentMessage in $Message)
        {
            Write-Log -Name $Name -Message $currentMessage -Level 'Verbose'
        }
    }
}