refactor(wakeup): use cmdletbinding, change var db name
This commit is contained in:
parent
47c313a26a
commit
fc3a39b0b9
13
wakeup.ps1
13
wakeup.ps1
@ -1,6 +1,7 @@
|
|||||||
<#
|
<#
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
# Array of strings listing computer name(s) to wake up. Names will be matched using RegEx
|
# Array of strings listing computer name(s) to wake up. Names will be matched using RegEx
|
||||||
@ -8,7 +9,7 @@ param
|
|||||||
[String[]]
|
[String[]]
|
||||||
$TargetComputer = "",
|
$TargetComputer = "",
|
||||||
# XML database file containing computer details (Default: WOLDatabase.xml)
|
# XML database file containing computer details (Default: WOLDatabase.xml)
|
||||||
[Alias("List", "database", "db")]
|
[Alias("List", "Database")]
|
||||||
[String]
|
[String]
|
||||||
$WolDatabase = "WOLDatabase.xml",
|
$WolDatabase = "WOLDatabase.xml",
|
||||||
# Skip connectivity check
|
# Skip connectivity check
|
||||||
@ -90,14 +91,14 @@ if ( [String]::IsNullOrWhiteSpace($TargetComputer))
|
|||||||
Write-Host
|
Write-Host
|
||||||
|
|
||||||
# read database and assemble list of target computers
|
# read database and assemble list of target computers
|
||||||
[xml]$db = Get-Content -Path $WolDatabase
|
[xml]$wolDb = Get-Content -Path $WolDatabase
|
||||||
$broadcastIP = $db.WOLDatabase.Configuration.BroadcastAddress
|
$broadcastIP = $wolDb.WOLDatabase.Configuration.BroadcastAddress
|
||||||
$port = $db.WOLDatabase.Configuration.Port
|
$port = $wolDb.WOLDatabase.Configuration.Port
|
||||||
$dnsSuffix = $db.WOLDatabase.Configuration.DnsSuffix
|
$dnsSuffix = $wolDb.WOLDatabase.Configuration.DnsSuffix
|
||||||
$targetComputers = [System.Collections.Generic.List[PSObject]]::new()
|
$targetComputers = [System.Collections.Generic.List[PSObject]]::new()
|
||||||
$TargetComputer | ForEach-Object {
|
$TargetComputer | ForEach-Object {
|
||||||
$tgt = $_
|
$tgt = $_
|
||||||
$db.WOLDatabase.Computers.Computer | Where-Object { $_.name -match $tgt } | ForEach-Object { $targetComputers.Add($_) }
|
$wolDb.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()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user