From 56bc398bf0a365f4864189dafd117a636e44dd6c Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sun, 5 Sep 2021 17:25:15 -0600 Subject: [PATCH] struct(wakeup): use list for target computers - prevent future multiple read of database file --- wakeup.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wakeup.ps1 b/wakeup.ps1 index 16f0919..99e603b 100644 --- a/wakeup.ps1 +++ b/wakeup.ps1 @@ -65,7 +65,10 @@ $broadcastIP = $db.WOLDatabase.Configuration.BroadcastAddress $port = $db.WOLDatabase.Configuration.Port $dnsSuffix = $db.WOLDatabase.Configuration.DnsSuffix -$db.WOLDatabase.Computers.Computer | Where-Object { $_.name -match "$targetComputer" } | ForEach-Object { +$targetComputers = [System.Collections.Generic.List[PSObject]]::new() +$db.WOLDatabase.Computers.Computer | Where-Object { $_.name -match "$targetComputer" } | ForEach-Object { $targetComputers.Add($_) } + +$targetComputers | ForEach-Object { if ( [String]::IsNullOrWhiteSpace($_.friendlyName)) { $name = $_.name