|
|
|
@ -1,23 +1,10 @@
|
|
|
|
#!powershell
|
|
|
|
#!powershell
|
|
|
|
# This file is part of Ansible
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
|
|
|
|
# (c) 2017, Dag Wieers <dag@wieers.com>
|
|
|
|
# Copyright: (c) 2017, Dag Wieers (@dagwieers) <dag@wieers.com>
|
|
|
|
#
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
#Requires -Module Ansible.ModuleUtils.Legacy
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# WANT_JSON
|
|
|
|
|
|
|
|
# POWERSHELL_COMMON
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
|
|
|
|
|
|
@ -47,7 +34,7 @@ if ($mac.Length -ne 12) {
|
|
|
|
|
|
|
|
|
|
|
|
# Create payload for magic packet
|
|
|
|
# Create payload for magic packet
|
|
|
|
# TODO: Catch possible conversion errors
|
|
|
|
# TODO: Catch possible conversion errors
|
|
|
|
$target = 0,2,4,6,8,10 | % { [convert]::ToByte($mac.Substring($_, 2), 16) }
|
|
|
|
$target = 0,2,4,6,8,10 | ForEach-Object { [convert]::ToByte($mac.Substring($_, 2), 16) }
|
|
|
|
$data = (,[byte]255 * 6) + ($target * 20)
|
|
|
|
$data = (,[byte]255 * 6) + ($target * 20)
|
|
|
|
|
|
|
|
|
|
|
|
# Broadcast payload to network
|
|
|
|
# Broadcast payload to network
|
|
|
|
|