{"id":18841681,"url":"https://github.com/asifbacchus/ps-cmdlet-wol","last_synced_at":"2025-07-09T17:38:04.513Z","repository":{"id":169612670,"uuid":"403189577","full_name":"asifbacchus/ps-cmdlet-wol","owner":"asifbacchus","description":"PowerShell Wake-On-Lan cmdlet to send magic packet(s) based on provided MAC address(es).","archived":false,"fork":false,"pushed_at":"2021-09-06T01:02:15.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-12T11:03:44.519Z","etag":null,"topics":["cmdlet","posh","powershell","powershell-module","wake-on-lan","wol"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asifbacchus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-05T01:29:55.000Z","updated_at":"2023-08-22T15:54:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"1760f023-e419-4999-baba-ff804ca1d61c","html_url":"https://github.com/asifbacchus/ps-cmdlet-wol","commit_stats":null,"previous_names":["asifbacchus/ps-cmdlet-wol"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/asifbacchus/ps-cmdlet-wol","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asifbacchus%2Fps-cmdlet-wol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asifbacchus%2Fps-cmdlet-wol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asifbacchus%2Fps-cmdlet-wol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asifbacchus%2Fps-cmdlet-wol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asifbacchus","download_url":"https://codeload.github.com/asifbacchus/ps-cmdlet-wol/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asifbacchus%2Fps-cmdlet-wol/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264502289,"owners_count":23618569,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmdlet","posh","powershell","powershell-module","wake-on-lan","wol"],"created_at":"2024-11-08T02:52:10.459Z","updated_at":"2025-07-09T17:38:04.152Z","avatar_url":"https://github.com/asifbacchus.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PowerShell cmdlet: Send Magic Packet\n\nPowerShell cmdlet (module/function) to send a *magic packet* based on provided MAC address(es). Comment-based help is\nincluded in the source-code: `Get-Help Send-MagicPacket -Full`\n\n## Contents\n\n\u003c!-- toc --\u003e\n\n- [Installation and verification](#installation-and-verification)\n    * [Example: Auto-load for current user](#example-auto-load-for-current-user)\n- [Overview](#overview)\n- [Broadcast considerations](#broadcast-considerations)\n- [Pipeline](#pipeline)\n- [Module or Function](#module-or-function)\n- [Feedback](#feedback)\n\n\u003c!-- tocstop --\u003e\n\n## Installation and verification\n\nDownloads are available via [my git server](https://git.asifbacchus.dev/asif/ps-cmdlet-wol/releases/latest)\nand [GitHub](https://github.com/asifbacchus/ps-cmdlet-wol/releases/latest). You may verify the cmdlet's integrity\nusing [CodeNotary](https://codenotary.io) via `vcn authenticate` or by dropping the downloaded script and/or manifest\nonto their verification webpage at [https://verify.codenotary.io](https://verify.codenotary.io). Please always try to\nverify downloaded scripts and software regardless of the source!\n\nIf you are integrating this function with your own project or want to manually load the module as needed, then save the\nmodule and manifest file wherever it is convenient for you. If you want to auto-load this function so it is available\nautomatically in any PowerShell session then you *must* extract it to a directory named **wol-magicPacket** somewhere\ndefined in your `PSModulePath` depending on your use-case. More information can be found directly from\nMicrosoft [here](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_modules?view=powershell-7.1#short-description)\n.\n\n### Example: Auto-load for current user\n\nHere's a complete example assuming I want the module automatically available for all sessions running under my user\naccount:\n\n```powershell\n# download version 2.0\nInvoke-WebRequest -Uri https://git.asifbacchus.dev/asif/ps-cmdlet-wol/archive/v2.0.zip -OutFile \"$Env:DOWNLOADS\\ps-cmdlet-wol.zip\"\n\n# Get PSModulePath\n# You should see a user-level modules path in the form of either:\n#  C:\\Users\\Username\\Documents\\WindowsPowerShell\\Modules  -OR-\n#  C:\\Users\\Username\\Documents\\PowerShell\\Modules\n$Env:PSModulePath\n\n# change directory to the appropriate path from above\nSet-Location \"C:\\Users\\Username\\Documents\\WindowsPowerShell\\Modules\"\n\n# extract files and rename directory\nExpand-Archive -Path \"$Env:DOWNLOADS\\ps-cmdlet-wol.zip\" -DestinationPath .\\\nRename-Item -Path ps-cmdlet-wol -NewName wol-magicPacket\n\n# confirm: you should see a directory named 'wol-magicPacket'\ngci\n\n# confirm: you should see the manifest and module within the wol-magicPacket folder\ngci .\\wol-magicPacket\n```\n\nNow, close and re-open PowerShell and the `Send-MagicPacket` function should be available:\n\n```powershell\nGet-Command Send-MagicPacket\n```\n\n## Overview\n\nThe function sends two (2) magic packets spaced one (1) second apart. One set of magic packets will be sent per MAC\naddress submitted either directly via the `MacAddress` parameter or via the pipeline (implicitly or explicitly). Usage\nexamples are provided via `Get-Help Send-MagicPacket -Examples`.\n\nThe only mandatory parameter is `MacAddress` which can be provided directly or via the pipeline either implicitly or\nexplicitly (parameter is in the first position). `MacAddress` is an *array of strings*. The actual hex values of the MAC\naddress can be separated with a colon (':') and/or a hyphen ('-'). For example, the following MAC addresses are all\nvalid even within the same command:\n\n```powershell\nSend-MagicPacket '1a:2b:3c:4d:5e:aa', 'a1-b2-c3-d4-e5-bb', '1a:2b-3c:4d-5e-cc'\n```\n\nBy default, the magic packet will be sent on the global broadcast address for your current system (e.g. 255.255.255.255)\nusing UDP on the *echo* port (7). These options can be customized via parameters:\n\n- `-BroadcastIP` | `IP` | `Address`: Broadcast address to use. By default, this is 255.255.255.255 but you really should\n  use a subnet specific broadcast address instead (e.g. 192.168.1.255). See\n  the [Broadcast considerations](#broadcast-considerations) section for more discussion.\n- `Port`: Allows changing the UDP port over which the magic packet is sent. This is by default port 7 (echo). Port 9 (\n  discard) is also quite common but any port can be used depending on your particular environment.\n\nThe magic packet is constructed as per standards: 6 byte header consisting of '255' (hex:FF) followed by the\nhex-represented MAC addresses repeated 16 times.\n\n## Broadcast considerations\n\nLong ago in a galaxy far away... actually a few decades ago right here on Earth, the easiest way to send Wake-On-Lan (\nWOL) packets was simply to use the global IP4 all-subnets broadcast address of 255.255.255.255. Because this generates a\nlot of un-needed traffic, breaks subnet isolation and can be an attack vector, many routers and switches now block this\ntype of broadcast. Although this remains the default for most WOL applications (including this function), it is vastly\nmore reliable and preferred to use a subnet-specific broadcast address. For example, if you are concerned with computers\non your subnet of 192.168.1.0/24 then you would use the broadcast address of 192.168.1.255.\n\nMore recently, it has also become somewhat common to use the multicast all-hosts address of **224.0.0.1** when sending\nWOL packets. If broadcast is not working in your environment, you may want to try this as a possible workaround.\n\nThings become a little more complicated with IP6. There is no concept of 'broadcast' in IP6 and thus, you need to use\nmulticast. I have not extensively tested IP6 WOL since I tend to continue using IP4 for this purpose (all my networks\nare dual-stack). I would assume the simplest place to start testing would be using the link-local all-nodes address\nof **ff02::1**. I suspect this should work across most networks, but I have not tested it extensively and it would\ndepend greatly on switches, routers and even machine specific set-ups.\n\n## Pipeline\n\nThis function is geared toward pipeline usage. The variable `MacAddress` is parameterized and used by the function for\nan array of string objects representing individual MAC addresses. This is consistent with WMIC/CIMv2 output for most NIC\nqueries and allows this function to be easily called using piped output from such a query. To see this, try sending some\ndummy magic packets to the localhost for all interfaces on the local machine:\n\n```powershell\n# get name, manufacturer and MAC address for connected interfaces and pipe to our function \nGet-CimInstance -Query \"Select * From Win32_NetworkAdapter Where NetConnectionStatus=2\" | Select-Object Name, Manufacturer, MacAddress | Send-MagicPacket -IP 127.0.0.1 -Verbose\n```\n\nYou will notice I've selected stuff we don't need (Name, Manufacturer) to show that the function can parse and pick up\nnamed the `MacAddress` of each object (network interface) and then send a magic packet to 127.0.0.1 on port 7 (echo).\nThis is not at all useful, but demonstrates pipeline usage quite nicely, I think. A simpler demonstration would be the\nfollowing:\n\n```powershell\n# send magic packets to two machines over IP4 localhost using port 9 (discard)\n'1a:2b:3c:4d:5e:aa', 'a1:b2:c3:d4:e5:bb' | Send-MagicPacket -BroadcastIP 127.0.0.1 -Port 9\n```\n\n## Module or Function\n\nThis was intended to be used as a simple function that can be integrated into other scripts directly or, more\nconveniently, loaded as a module and referenced as needed in a variety of use-cases.\n\nIf using as a function, simply place it within your script. If you want to load it as a module either `Load-Module`\nwithin your script or do so at a PS prompt:\n\n```powershell\n# load module\nLoad-Module C:\\path\\to\\module\\wol-magicPacket.psm1\n\n# call module anytime after loading within the same session\nSend-MagicPacket ...\n```\n\n## Feedback\n\nI coded this pretty quickly for a project I was working on in a small LAN deployment. I also use it routinely in\nnetworks of various sizes and over VPN connections and also when I'm too lazy to move from my office to the living room\nto turn on my media centre. I've polished it up and added comment-based help for the version in this repo, hence the\nmore recent creation date. I'm always interested in improvements since I don't code in PowerShell that often and I'm\nsure this can be vastly improved. Please send any suggestions, bugs, etc. to me by filing an issue.\n\nI hope you find this useful! As indicated by the license, you can use this code for whatever you want in any capacity.\nIf you do use it, a link to my blog at [https://mytechiethoughts.com](https://mytechiethoughts.com) would be greatly\nappreciated!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasifbacchus%2Fps-cmdlet-wol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasifbacchus%2Fps-cmdlet-wol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasifbacchus%2Fps-cmdlet-wol/lists"}