Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
a0aa0680ef | |||
b968fdf93e | |||
d5c3c071cd |
@ -38,8 +38,8 @@ ### Example: Auto-load for current user
|
|||||||
account:
|
account:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# download version 1.1
|
# download version 2.0
|
||||||
Invoke-WebRequest -Uri https://git.asifbacchus.dev/asif/ps-cmdlet-wol/archive/v1.1.zip -OutFile "$Env:DOWNLOADS\ps-cmdlet-wol.zip"
|
Invoke-WebRequest -Uri https://git.asifbacchus.dev/asif/ps-cmdlet-wol/archive/v2.0.zip -OutFile "$Env:DOWNLOADS\ps-cmdlet-wol.zip"
|
||||||
|
|
||||||
# Get PSModulePath
|
# Get PSModulePath
|
||||||
# You should see a user-level modules path in the form of either:
|
# You should see a user-level modules path in the form of either:
|
||||||
|
Binary file not shown.
@ -50,7 +50,6 @@ function Send-MagicPacket
|
|||||||
ValueFromPipelineByPropertyName,
|
ValueFromPipelineByPropertyName,
|
||||||
HelpMessage = "Please provide one or more MAC addresses. You may use a colon (:) or a hypen (-) to separate hex values."
|
HelpMessage = "Please provide one or more MAC addresses. You may use a colon (:) or a hypen (-) to separate hex values."
|
||||||
)]
|
)]
|
||||||
[ValidatePattern('^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$')]
|
|
||||||
[String[]]
|
[String[]]
|
||||||
$MacAddress,
|
$MacAddress,
|
||||||
|
|
||||||
@ -83,6 +82,13 @@ function Send-MagicPacket
|
|||||||
{
|
{
|
||||||
foreach ($addr in $MacAddress)
|
foreach ($addr in $MacAddress)
|
||||||
{
|
{
|
||||||
|
# validate MAC address format or write error and continue
|
||||||
|
if (!($addr -match '^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$'))
|
||||||
|
{
|
||||||
|
Write-Error "Invalid MAC address: $addr"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
# convert MAC address to magic packet
|
# convert MAC address to magic packet
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -97,7 +103,7 @@ function Send-MagicPacket
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Write-Warning "Unable to process MAC address: $thisMacAddress"
|
Write-Error "Unable to process MAC address: $thisMacAddress"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +118,7 @@ function Send-MagicPacket
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Write-Warning "Unable to send magic packet for '$addr'"
|
Write-Error "Unable to send magic packet for '$addr'"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user