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
<#
.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