feature(wakeup): exit if no matching computers found

This commit is contained in:
Asif Bacchus 2021-09-05 22:48:20 -06:00
parent e5bc1f76df
commit 2a21a23462

View File

@ -75,6 +75,13 @@ $targetComputers = [System.Collections.Generic.List[PSObject]]::new()
$db.WOLDatabase.Computers.Computer | Where-Object { $_.name -match "$targetComputer" } | ForEach-Object { $targetComputers.Add($_) } $db.WOLDatabase.Computers.Computer | Where-Object { $_.name -match "$targetComputer" } | 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)
if ($targetComputers.Count -eq 0)
{
Write-Host -ForegroundColor Yellow "No computers found matching '$targetComputer'. Nothing to do.`r`n"
exit 0
}
# send WOL magic packets # send WOL magic packets
$targetComputers | ForEach-Object { $targetComputers | ForEach-Object {
$wolError = @() $wolError = @()