Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Using PDQ-WOL from an external application

Hello PDQ Community

Is there a way to pass some mac-adresses or hostnames from a commandline to PDQ-Inventory and let PDQ-Inventory do the wakeup-job then? I know pdq uses it's "own" way to do WOL by sending 3 broadcast-udp pakets to the general broadcast address and also 3 directed UDP pakets to the subnet of the targets on ports 9, 12287 and 40000. I like to use that from a commandline (If possible, without first having to extract the required informations from the sqlite database).

Any help would be appreciated.

0

Comments

1 comment
Date Votes
  • I am not sure if there is a way to kick off the actual PDQ job via a command line, but if it helps, here is just an old PowerShell script that I had laying around which my old boss made. You can modify it to include the other extra ports that PDQ normally uses.

    ##########
    #
    # Script to send a "magic packet" for Wake-On-LAN
    # 1/8/2013
    # Required input: Target machine's MAC address in a dash- or 
    # colon-separated form, e.g., 00-0C-F1-CA-96-C3
    #
    [cmdletbinding()]
    param (
        [Alias('MacAddress')]
        [String]$macString = $(throw 'MAC address is required'))
    
    $macString = $macString.ToUpper()
    $mac = $macString.Split('-:') | % { [byte]('0x' + $_) }
    if ($mac.Length -ne 6)
    {
       throw 'MAC address must be 6 hex numbers separated by dashes or colons'
    }
     
    $UDPclient = new-Object System.Net.Sockets.UdpClient
    $UDPclient.Connect(([System.Net.IPAddress]::Broadcast),4000)
    $packet = [byte[]](,0xFF * 6)
    $packet += $mac * 16
     
    Write-Verbose ([bitconverter]::tostring($packet))
     
    [void] $UDPclient.Send($packet, $packet.Length)
    
    Write-Verbose "Wake-On-Lan magic packet of length $($packet.Length) sent to $macString"
    
    0