Created
January 28, 2019 00:36
-
-
Save smaglio81/d7849a05ec8adffaa4163435a5c5e521 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Send-Notification { | |
param( | |
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | |
[string] $Component, | |
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | |
[ValidateSet("Debug","Information","Warning","Error","Validation")] | |
[string] $MessageType, | |
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | |
[string[]] $Tags, | |
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | |
[string] $ID, | |
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | |
[string] $Message, | |
[Parameter(ValueFromPipelineByPropertyName = $true)] | |
[string] $CreatedBy = $env:USERNAME, | |
[Parameter(ValueFromPipelineByPropertyName = $true)] | |
[DateTime] $CreatedDate = [DateTime]::Now | |
) | |
$notification = New-Notification @PSBoundParameters | |
. "$($global:Notifications.AMModule)\Save-Notification" -Notification $notification | |
$subscriptions = . "$($global:Notifications.CMModule)\Select-MatchingSubscription" ` | |
-Component $Component ` | |
-MessageType $MessageType ` | |
-Tags $Tags | |
foreach($subscription in $subscriptions) { | |
$senderModule = "NS{0}" -f $subscription.ContactType | |
if((Get-Module $senderModule) -eq $null) { | |
throw ( | |
("Send-Notification: Sub-module '{0}' needs to be loaded before notifications " + | |
"can be sent to the {1} contact type. If this is an unknown contact type, please " + | |
"ensure the subscription which contains that contact type is updated to a known type.") -f | |
$senderModule, $subscription.ContactType | |
) | |
} | |
. "$senderModule\Send-NotificationToSubscription" -Notification $notification -Subscription $subscription | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment