PoshCode Archive  Artifact Content

Artifact e2a1b980fb87439ec6a48128debcd70ea9f21e361533c702d46ea151d9be05d3:

  • File restart-wifi-and-say-it.ps1 — part of check-in [3fba4dede1] at 2018-06-10 14:11:37 on branch trunk — Restart wireless service and say it (user: hellorobo size: 1387)

# encoding: utf-8
# api: powershell
# title: restart wifi and say it
# description: Restart wireless service and say it
# version: 1.0
# type: function
# author: hellorobo
# license: CC0
# function: Speak-Text
# x-poshcode-id: 6257
# x-archived: 2016-08-17T11:36:22
# x-published: 2016-03-18T09:51:00
#
#
function Speak-Text
{
    [CmdletBinding()]
    [OutputType([int])]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        [string]$text
    )

    Begin
    {
        $speaker = New-Object -com SAPI.SpVoice
    }
    Process
    {
        $speaker.Speak($text)
    }
    End
    {
        $speaker.Dispose()
    }
}

Write-Output "Checking if Wi-Fi is working ... ?"
$Test = (Test-Connection -Quiet plkon-nt7000)
Write-Output "... $Test"
if ($Test -eq $False) {
    Speak-Text "Och nie, chyba nie mam po³¹czenia do systemu N te 7000"
    Restart-NetAdapter -Name Wi-Fi
    Start-Sleep 5
    netsh wlan connect name=mcn-forklift 
    Speak-Text "Nie martw siê, pracuj dalej, zrestartowa³am za ciebie po³¹czenie z bezprzewodówk¹, bo wiem ¿e masz wa¿niejsze sprawy na g³owie"

}

# C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
# -command "& 'C:\Scripts\s_Restart-WiFi.ps1'