Compare commits
3 Commits
98ab3f4f7e
...
7faa4d84c4
Author | SHA1 | Date |
---|---|---|
Asif Bacchus | 7faa4d84c4 | |
Asif Bacchus | abcbdb274d | |
Asif Bacchus | 10b0bfbdfa |
|
@ -0,0 +1,13 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/.idea.ps-cmdlet-wol.iml
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="asif" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CommitMessageInspectionProfile">
|
||||
<profile version="1.0">
|
||||
<inspection_tool class="BodyLimit" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="SubjectBodySeparation" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="SubjectLimit" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<db>
|
||||
<Configuration>
|
||||
<AlwaysAuthorized>
|
||||
"ITStaff",
|
||||
"Administrators",
|
||||
"Domain Admins"
|
||||
</AlwaysAuthorized>
|
||||
</Configuration>
|
||||
<Computers>
|
||||
<Computer name="Computer001" mac="AA:1A:2A:3A:4A:01" authorized="any"/>
|
||||
<Computer name="Computer002" mac="BB:1B:2B:3B:4B:02" authorized="Managers"/>
|
||||
<Computer name="Computer003" mac="CC:1C:2C:3C:4C:03" authorized="User3"/>
|
||||
</Computers>
|
||||
</db>
|
|
@ -0,0 +1,79 @@
|
|||
function Send-MagicPacket
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
# Array of MAC addresses for which to construct magic packets
|
||||
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
|
||||
[ValidatePattern('^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$')]
|
||||
[String[]]
|
||||
$MacAddress,
|
||||
|
||||
# Broadcast IP address (default: all subnets --> 255.255.255.255)
|
||||
[Parameter()]
|
||||
[IPAddress]
|
||||
$BroadcastIP = [System.Net.IPAddress]::Broadcast,
|
||||
|
||||
# UDP port over which to broadcast magic packet (default: 7)
|
||||
[Parameter()]
|
||||
[Int16]
|
||||
$Port = 7
|
||||
)
|
||||
|
||||
begin
|
||||
{
|
||||
# instantiate UDP client
|
||||
try
|
||||
{
|
||||
$UdpClient = [System.Net.Sockets.UdpClient]::new()
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Error "Unable to instantiate UDP Client to send magic packets"
|
||||
}
|
||||
}
|
||||
|
||||
process
|
||||
{
|
||||
foreach ($addr in $MacAddress)
|
||||
{
|
||||
# convert MAC address to magic packet
|
||||
try
|
||||
{
|
||||
# construct byte-array from MAC address
|
||||
$MAC = $addr -split '[:-]' | ForEach-Object {
|
||||
[Byte]"0x$_"
|
||||
}
|
||||
|
||||
# construct magic packet
|
||||
# first 6 bytes = FF (255) then repeat MAC address 16 times
|
||||
[Byte[]]$magicPacket = (,0xFF * 6) + ($MAC * 16)
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Warning "Unable to process MAC address: $thisMacAddress"
|
||||
continue
|
||||
}
|
||||
|
||||
# broadcast magic packet
|
||||
try
|
||||
{
|
||||
$UdpClient.Connect($BroadcastIP, $Port)
|
||||
$UdpClient.Send($magicPacket, $magicPacket.Length) | Out-Null
|
||||
Write-Verbose "Sent magic packet: Broadcast $addr over $BroadcastIP on port $Port (UDP)"
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Warning "Unable to send magic packet for '$addr'"
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
{
|
||||
# dispose of UDP client
|
||||
$UdpClient.Close()
|
||||
$UdpClient.Dispose()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue