From f78b415db0797e6af7e8f965b13fab46296dc7b0 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Wed, 21 Mar 2018 23:45:17 +0100 Subject: [PATCH] win_wakeonlan: Fix pslint issues (#37717) --- lib/ansible/modules/windows/win_wakeonlan.ps1 | 25 +++++-------------- test/sanity/pslint/ignore.txt | 1 - 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/ansible/modules/windows/win_wakeonlan.ps1 b/lib/ansible/modules/windows/win_wakeonlan.ps1 index de40c32af2c..e9abdcb474e 100644 --- a/lib/ansible/modules/windows/win_wakeonlan.ps1 +++ b/lib/ansible/modules/windows/win_wakeonlan.ps1 @@ -1,23 +1,10 @@ #!powershell -# This file is part of Ansible -# -# (c) 2017, Dag Wieers -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# 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 . +# -*- coding: utf-8 -*- -# WANT_JSON -# POWERSHELL_COMMON +# Copyright: (c) 2017, Dag Wieers (@dagwieers) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +#Requires -Module Ansible.ModuleUtils.Legacy $ErrorActionPreference = "Stop" @@ -47,7 +34,7 @@ if ($mac.Length -ne 12) { # Create payload for magic packet # 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) # Broadcast payload to network diff --git a/test/sanity/pslint/ignore.txt b/test/sanity/pslint/ignore.txt index cd278060172..f1548cf3fe4 100644 --- a/test/sanity/pslint/ignore.txt +++ b/test/sanity/pslint/ignore.txt @@ -113,7 +113,6 @@ lib/ansible/modules/windows/win_unzip.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_uri.ps1 PSAvoidUsingConvertToSecureStringWithPlainText lib/ansible/modules/windows/win_user.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/win_wait_for.ps1 PSAvoidUsingEmptyCatchBlock -lib/ansible/modules/windows/win_wakeonlan.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/win_webpicmd.ps1 PSAvoidUsingInvokeExpression lib/ansible/modules/windows/win_webpicmd.ps1 PSUseOutputTypeCorrectly test/integration/targets/win_audit_rule/library/test_get_audit_rule.ps1 PSAvoidUsingCmdletAliases