Public/Set-FileEMailConfig.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
<#
    .SYNOPSIS
    Reads the email configuration from an XML file and persists in a script level variable

    .DESCRIPTION
    Reads the email configuration from an XML file in the CliXml format.

    .INPUTS
    None. You cannot pipe objects to Set-FileEmailConfig.

    .OUTPUTS
    None.

    .PARAMETER Path
    The path to the CliXMl file. Defaults to "email-config.xml"
#>

function Set-FileEmailConfig {

    [CmdletBinding()]
    [OutputType([System.Void])]
    param(
        [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline)]
        [String]
        $Path = "email-config.xml"
    )

    begin {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
    }

    end {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
    }

    process {
        Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"
        Set-Variable -Name __emailconfig -Scope Script -Value (Import-CliXml -Path $Path)
    }
}