FunctionNew-NotificationCenterNotification{<#.SYNOPSIS Send Notification Center to endpoint.DESCRIPTION Leveraging osascript, you can send Notification Center messages to a computer, be it local or remote.PARAMETER Title The Title displayed in the Toast notification.PARAMETER Message The body of the Toast notification.PARAMETER Computername Remote computer(s) to send notification too..EXAMPLE New-NotificationCenterNotification -Title "Test Message" -Message "This is a test of Toast Notifications".EXAMPLE New-NotificationCenterNotification -Title "Cmdlet Data" -Message "$((Get-Process safari).ProcessName)".EXAMPLE New-Notification -Title "Test Message" -Message "This is run on a remote computer" -Computername pc1.EXAMPLE New-Notification -Title "Test Message" -Message "I can send to multiple computers" -Computername pc1,pc2,pc3 #>Param([cmdletBinding()][Parameter(Mandatory,Position=0)][String]$Title,[Parameter(Mandatory,Position=1,ValueFromPipeline=$true)][String]$Message,[parameter(Mandatory=$false,Position=2)][String[]]$Computername)Begin{}Process{$Command="Display notification \`"$Message\`" with title \`"$Title\`""If(!$Computername){osascript-e"$Command"}Else{Foreach($cin$Computer){Invoke-Command-ComputerName$c-ScriptBlock{$args[0]}-ArgumentList$Command}}#else}#process}#function
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.