feature(wakeup): allow specifying multiple computers and patterns

- change TargetComputer to array of strings each matched via RegEx
This commit is contained in:
Asif Bacchus 2021-09-06 01:19:13 -06:00
parent 0ce3ebdb35
commit 4a8fff4384

View File

@ -3,9 +3,9 @@
param param
( (
# Computer to wake up # Array of strings listing computer name(s) to wake up. Names will be matched using RegEx
[Alias("Computer")] [Alias("Computer")]
[String] [String[]]
$TargetComputer = "", $TargetComputer = "",
# XML database file containing computer details # XML database file containing computer details
[Alias("List", "database", "db")] [Alias("List", "database", "db")]
@ -89,7 +89,10 @@ $broadcastIP = $db.WOLDatabase.Configuration.BroadcastAddress
$port = $db.WOLDatabase.Configuration.Port $port = $db.WOLDatabase.Configuration.Port
$dnsSuffix = $db.WOLDatabase.Configuration.DnsSuffix $dnsSuffix = $db.WOLDatabase.Configuration.DnsSuffix
$targetComputers = [System.Collections.Generic.List[PSObject]]::new() $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() $removeFromTargetComputers = [System.Collections.Generic.List[String]]::new()
# exit if nothing to do (i.e. empty targetComputers list) # exit if nothing to do (i.e. empty targetComputers list)