Public/Basic/New-BTAppId.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
function New-BTAppId
{
    <#
        .SYNOPSIS
 
        .DESCRIPTION
         
        .PARAMETER AppId
 
        .INPUTS
        System.String
 
        You cannot pipe input to this cmdlet.
 
        .OUTPUTS
        None
 
        .NOTES
        The New-BTAppId function is classified as: Basic
 
        .EXAMPLE
 
        .EXAMPLE
         
        .LINK
        https://github.com/Windos/BurntToast/blob/master/Help/New-BTAppId.md
    #>


    param
    (
        [Parameter()]
        [ValidateNotNullOrEmpty()] 
        [string] $AppId = $Script:Config.AppId
    )
    
    $RegPath = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings'
    
    if (!(Test-Path -Path "$RegPath\$AppId"))
    {
        $null = New-Item -Path $RegPath -Name $AppId
        $null = New-ItemProperty -Path "$RegPath\$AppId" -Name 'ShowInActionCenter' -Value 1 -PropertyType 'DWORD'
    }
    else
    {
        Write-Warning -Message 'Specified AppId is already present in the registry.'
    }
}