none
Wake on LAN PS Script RRS feed

  • Question

  • HI all,

             I borrowed this script from someone smarter than me, it does not work can anyone point out my error?

      

    function Send-WOL
    {
    <# 
      .SYNOPSIS  
        Send a WOL packet to a broadcast address
      .PARAMETER mac
       The MAC address of the device that need to wake up
      .PARAMETER ip
       The IP address where the WOL packet will be sent to
      .EXAMPLE 
       Send-WOL -mac 00:11:32:21:2D:11 -ip 192.168.8.255 
    #>

    [CmdletBinding()]
    param(
    [Parameter(Mandatory=$True,Position=1)]
    [string]$mac,"00:24:21:7A:9D:37",
    [string]$ip="255.255.255.255", 
    [int]$port=7
    )
    $broadcast = [Net.IPAddress]::Parse($ip)

    $mac=(($mac.replace(":","")).replace("-","")).replace(".","")
    $target=0,2,4,6,8,10 | % {[convert]::ToByte($mac.substring($_,2),16)}
    $packet = (,[byte]255 * 6) + ($target * 16)

    $UDPclient = new-Object System.Net.Sockets.UdpClient
    $UDPclient.Connect($broadcast,$port)
    [void]$UDPclient.Send($packet, 102) 

    }

    Any Thoughts welcome

    • Moved by Bill_Stewart Tuesday, December 11, 2018 11:26 PM This is not "debug/fix/rewrite my script for me" forum
    Tuesday, August 7, 2018 8:23 PM