From 4a8fff43841495cc225a4f4f9445934983ccad6c Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Mon, 6 Sep 2021 01:19:13 -0600 Subject: [PATCH] feature(wakeup): allow specifying multiple computers and patterns - change TargetComputer to array of strings each matched via RegEx --- wakeup.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wakeup.ps1 b/wakeup.ps1 index 9518a1e..d3b4900 100644 --- a/wakeup.ps1 +++ b/wakeup.ps1 @@ -3,9 +3,9 @@ param ( -# Computer to wake up +# Array of strings listing computer name(s) to wake up. Names will be matched using RegEx [Alias("Computer")] - [String] + [String[]] $TargetComputer = "", # XML database file containing computer details [Alias("List", "database", "db")] @@ -89,7 +89,10 @@ $broadcastIP = $db.WOLDatabase.Configuration.BroadcastAddress $port = $db.WOLDatabase.Configuration.Port $dnsSuffix = $db.WOLDatabase.Configuration.DnsSuffix $targetComputers = [System.Collections.Generic.List[PSObject]]::new() -$db.WOLDatabase.Computers.Computer | Where-Object { $_.name -match "$TargetComputer" } | ForEach-Object { $targetComputers.Add($_) } +$TargetComputer | ForEach-Object { + $tgt = $_ + $db.WOLDatabase.Computers.Computer | Where-Object { $_.name -match $tgt } | ForEach-Object { $targetComputers.Add($_) } +} $removeFromTargetComputers = [System.Collections.Generic.List[String]]::new() # exit if nothing to do (i.e. empty targetComputers list)