examples/example-1.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

function New-CustomVm
{
    [cmdletbinding(SupportsShouldProcess)]
    param(
    )

    if ($PSCmdlet.ShouldProcess("Target", "Operation"))
    {
        try
        {
            # Remove-Item -Verbose -Path 'C:\mgotest.txt' -ErrorAction Stop
            # ...
            Write-Verbose -Message 'Verbose message'

            # ...
            Write-Warning -Message 'Warning message'

            1 / 0
        }
        catch
        {
            Write-Error -Message $_.Exception.Message
        }
    }
}
Import-Module PSEasyLog
New-CustomVm