Private/Pop-LinuxNotification.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
# The function that handles Linux notifications
function Pop-LinuxNotification {
    [CmdletBinding(SupportsShouldProcess=$true)]
    param (
        [Parameter(Mandatory=$true, ValueFromPipeline=$true)]
        [string]
        $Body,

        [Parameter(Mandatory=$true)]
        [string]
        $Title,

        [Parameter()]
        [string]
        $Icon
    )

    $splat = @{
        Body = $Body
        Summary = $Title
    }

    if ($Icon) {
        $splat.Add('Icon', $Icon)
    }

    if($PSCmdlet.ShouldProcess("running: PSNotifySend\Send-PSNotification $(ConvertTo-ParameterString $splat)")) {
        PSNotifySend\Send-PSNotification @splat
    }
}