InvokeSpeach.psm1

function Invoke-Speach {
<#
.SYNOPSIS
Speaks a message to a local or remote computer
.DESCRIPTION
Uses the speach synthasis feater to speak a message through the computers speakers
.PARAMETER Message
The message that is to be spoken
.PARAMETER ComputerName
The remote computer to send the message to
.EXAMPLE
Invoke-Speach -Message "Hello Bobby" -ComputerName "IT-computer"
.NOTES
Copyright (C) MosaicMK Software LLC - All Rights Reserved
Unauthorized copying of this application via any medium is strictly prohibited Proprietary and confidential
Written by MosaicMK Software LLC (contact@mosaicmk.com)
 
By using this software you agree to the following:
Agreement Permission is hereby granted, free of charge, to any person or organization obtaining a copy of this software and associated documentation files (the 'Software'),
to deal in the Software and the rights to use and distribute the software so long a no licensing and or documentation files are remove, revised or modified
the Software is furnished to do so, subject to the following conditions:
 
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
Contact: Contact@MosaicMK.com
Version 1.2.1
.LINK
https://www.mosaicmk.com
#>


PARAM(
    [Parameter(Mandatory=$true)]
    [String]$Message,
    [string]$ComputerName,
    [Parameter(Mandatory=$true)]
    [ValidateSet('Microsoft Zira Desktop','Microsoft David Desktop')]
    [string]$Voice
)
    if (!($Voice)){$Voice = 'Microsoft David Desktop'}
    if ($ComputerName){Invoke-Command -ComputerName $ComputerName -ScriptBlock {
        $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer 
        $speak.SelectVoice("$Voice")
        $speak.Speak("$Message")}
    }else {
        $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
        $speak.SelectVoice("$Voice")
        $speak.Speak("$Message")
    }
}