Wednesday, 16 December 2015

Speech with windows powershell

Set-ExecutionPolicy Unrestricted -Force

<#
.Synopsis
   Allows you to speak on a remote computer
   Requires that you have run winrm qc on the remote machine
   or Enable-PSRemoting. And on the local machine you've changed
   Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value * -Force 
.DESCRIPTION
   Allows you to speak on a remote computer
.EXAMPLE
   Speak-Remote 1 "How are you today" REMOTE_PC
.EXAMPLE
   Speak-Remote -RemoteComputerName REMOTE_PC
#>
function Speak-Remote
{
    [CmdletBinding()]
    [OutputType([int])]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        [string]
        $Times = (Read-Host "How many Times"),

        # Param2 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=1)]
        [string]
        $Message = (Read-Host "What should I say"),

        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=2)]
        [string]
        $RemoteComputerName
    )

    Begin
    {
    }
    Process
    {
        Invoke-Command -ScriptBlock {Param($msg, $n) Add-Type -AssemblyName System.Speech; $o = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer; $o.SelectVoice("Microsoft Zira Desktop") ; $y = 0; do { $o.Speak($msg);$y = $y + 1;} until ($y -eq $n) } -ComputerName $RemoteComputerName -ArgumentList $Message, $Times
    }
    End
    {
    }
}

Speak-Remote -RemoteComputerName REMOTE_PC

No comments:

Post a Comment

How to by pass the Jaguary X-Type enter security pin screen after changing battery

How to bypass security code on Jaguar X-Type touchscreen Satellite Navigational units. Just hold the skip track, AMEM and PTY buttons ...