# Trying to use WakeOnLan and keep getting errors

**URL:** https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610
**Category:** PowerShell Help
**Created:** [March 21, 2025, 8:24pm UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610 "2025-03-21T20:24:54Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Glen\_Harouff](https://avatars.discourse-cdn.com/v4/letter/g/f05b48/32.png) [@Glen\_Harouff](https://forums.powershell.org/u/Glen_Harouff)
#### Post date: [March 21, 2025, 8:24pm UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/1 "2025-03-21T20:24:54Z")

</div>

CoPilot was not helpful in trying to get WakeOnLan to function. Nothing seems to work. Does WakeOnLan command ever work. Using PowerShell 7.

I get these types of errors:  
PS C:\Users\gharouff\_dadmin.METROHEALTH\> import-module wakeonlan

PS C:\Users\gharouff\_dadmin.METROHEALTH\> Invoke-wakeonlan -MacAddress 40:1c:83:40:ad:3f

InvalidArgument: Cannot convert value “0x40:1c:83:40:ad:3f” to type “System.Byte”. Error: "Additional non-parsable characters are at the

end of the string."

I used “-” instead of “:” and get the same error

Imported and installed WakeOnLan modules installed ok  
Used Get-Command -Module WakeOnLan – returned command type – Function, Name – Invoke-WakeOnLan, version 1.0, source wakeonlan

---

<div class="post-metadata">

### Author: ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)
#### Post date: [March 21, 2025, 9:14pm UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/2 "2025-03-21T21:14:24Z")

</div>

I cannot reproduce. I recommend you type the mac instead of copy/pasting, it’s likely there are additional characters you can’t see.

---

<div class="post-metadata">

### Author: ![grey0ut](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/grey0ut/32/5310_2.png) [@grey0ut](https://forums.powershell.org/u/grey0ut)
#### Post date: [March 21, 2025, 9:25pm UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/3 "2025-03-21T21:25:08Z")

</div>

Hello and welcome to the forum.  
Whenever you’re sharing code please make sure to use the Preformatted text button. It’s often behind the gear icon.

The first thing I did was look up the module you’re using. [WakeOnLane](https://github.com/ChrisWarwick/WakeOnLan) was published to the PowerShell Gallery in 2015 and written with Powershell v2 as a minimum. Just things to keep in mind.

```auto
InvalidArgument: Cannot convert value "0x40:1c:83:40:ad:3f" to type "System.Byte"

```

Your MAC address suddenly has a `0x40` at the beginning of it instead of your original “40”.  
The param block from the source code takes your input in as a string:

```Powershell
Param (
    [Parameter(ValueFromPipeline)]
    [String[]]$MacAddress
)

```

And later converts it to bytes:

```Powershell
$Mac = $MacString.Split('-:') | Foreach {[Byte]"0x$_"}

 # WOL Packet is a byte array with the first six bytes 0xFF, followed by 16 copies of the MAC address

$Packet = [Byte[]](,0xFF * 6) + ($Mac * 16)

```

When I run just the relevant code in Windows Powershell v5.1 it works.  
When I run it in Powershell 7.5 it fails with the error:

```auto
InvalidArgument: Cannot convert value "0x40:1c:83:40:ad:3f" to type "System.Byte". Error: "Additional non-parsable characters are at the end of the string."

```

I don’t know which part of this syntax it doesn’t like:

```Powershell
$Mac = $MacString.Split('-:') | Foreach {[Byte]"0x$_"}

```

But that’s your problem.

Seeing your PS prompt in your posted text we can see you’re on a Windows machine. I would advise using Windows Powershell to use this module instead.  
I would also advise you edit your post and remove your username from your prompt as it reveals potentially sensitive information about your organization.

EDIT: got it. The author used the Split() method of a String object and included two characters to potentially split on: -, ;  
In Windows Powershell v5.1, and .NET framework 4.5 that works:

```Powershell
# v5.1
PS> $MacString = "40:1c:83:40:ad:3f"
PS> $MacString.Split('-:')   
40
1c
83
40
ad
3f

```

But in PS v7.5 it doesn’t split at all:

```Powershell
# v7.5
PS> $MacString = "40:1c:83:40:ad:3f"
PS> $MacString.Split('-:')  
40:1c:83:40:ad:3f

```

The definition on [Microsoft’s docs]( [String.Split Method (System) | Microsoft Learn](https://learn.microsoft.com/en-us/dotnet/api/system.string.split?view=net-9.0#system-string-split(system-char()))) for both version of .NET says that Split will accept an array of characters as delimiters. But simply passing `'-:'` isn’t strictly an array, but somehow this worked in older versions of Powershell.  
I was able to make it work in both versions by literally creating a character array.

```Powershell
$MacString = "40:1c:83:40:ad:3f"
[Char[]]$Chars = [Char]'-',[Char]':'
$MacString.Split($Chars)# | Foreach {[Byte]"0x$_"}

```

@LearnLaughOps solution of switching to the -Split operator with Regex pattern of _This_|_That_ is what I would do.  
You can edit your local copy of the module manually yourself, open an issue on github, or fork the project for yourself.

---

<div class="post-metadata">

### Author: ![LearnLaughOps](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/learnlaughops/32/5688_2.png) [@LearnLaughOps](https://forums.powershell.org/u/LearnLaughOps)
#### Post date: [March 21, 2025, 9:36pm UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/4 "2025-03-21T21:36:58Z")

</div>

To resolve this I think you can just edit the module and update the following line:  
`$Mac = $MacString.Split('-:') | Foreach {[Byte]"0x$_"}`

Updated to:  
`$Mac = $MacString -split '-|:' | Foreach {[Byte]"0x$_"}`

I can’t figure out what changed from version 5-7.

---

<div class="post-metadata">

### Author: ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)
#### Post date: [March 21, 2025, 9:39pm UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/5 "2025-03-21T21:39:37Z")

</div>

Looks like a known problem. There is a fix, but the PR hasn’t been completed so there’s no updated version on the gallery.

> <https://github.com/ChrisWarwick/WakeOnLan/issues/2>
>
> \`Invoke-WakeOnLan\` seems to fail to parse mac addresses in either format . $Mac…String.Split('-:') no longer accepts multiple field separators . Thanks for the great module, with the small fix below it seems to work. I'll see if I can help with a backward-compat fix.
> 
> \## STEPS
> \`\`\`
> Invoke-WakeOnLan 00-1F-D0-98-CD-44
> Invoke-WakeOnLan C0:B6:F9:93:23:12
> 
> \`\`\`
> 
> \## Actual Results
> InvalidArgument: Cannot convert value "0x00-1F-D0-98-CD-44" to type "System.Byte". Error: "Additional non-parsable characters are at the end of the string."
> 
> \## Expected Results
> \> VERBOSE: Wake-on-Lan Packet sent to C0:B6:F9:93:23:12
> 
> \## Proof of Concept Diff
> \`\`\`
> @@ -119,7 +119,7 @@ Param (
> 
> # Split and convert the MAC address to an array of bytes
> 
> \- $Mac = $MacString.Split('-:') | Foreach {\[Byte\]"0x$\_"}
> + $Mac = $MacString.Split(':') | Foreach {\[Byte\]"0x$\_"}
> 
> # WOL Packet is a byte array with the first six bytes 0xFF, followed by 16 copies of the MAC address
> \`\`\`
> 
> \## Version Info
> \`\`\`
> ❯ $PSVersionTable
> 
> Name Value
> \---- -----
> PSVersion 7.4.2
> PSEdition Core
> GitCommitId 7.4.2
> OS Microsoft Windows 10.0.22635
> Platform Win32NT
> PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
> PSRemotingProtocolVersion 2.3
> SerializationVersion 1.1.0.1
> WSManStackVersion 3.0
> 
> \`\`\`

Might be worth trying this branch of the fork from the author of the fix:

> **[GitHub - tonymet/WakeOnLan at cannot-convert-value-issue-2](https://github.com/tonymet/WakeOnLan/tree/cannot-convert-value-issue-2)**
>
> cannot-convert-value-issue-2

---

<div class="post-metadata">

### Author: ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)
#### Post date: [March 21, 2025, 9:51pm UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/6 "2025-03-21T21:51:01Z")

</div>

I see, I didn’t try it in powershell core, so that’s my mistake! OP you could use my function if you like, it works in 7.x as well

> <https://github.com/krzydoug/Tools/blob/master/Send-WakeOnLan.ps1>

---

<div class="post-metadata">

### Author: ![grey0ut](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/grey0ut/32/5310_2.png) [@grey0ut](https://forums.powershell.org/u/grey0ut)
#### Post date: [March 21, 2025, 9:55pm UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/7 "2025-03-21T21:55:34Z")

</div>

awesome @krzydoug I was just scaffolding out a new module project based on this conversation. Hope you don’t mind if I borrow some of your code.

---

<div class="post-metadata">

### Author: ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)
#### Post date: [March 22, 2025, 12:21am UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/8 "2025-03-22T00:21:27Z")

</div>

Not at all. This is my number 1 visited script and most those visiting come from Reddit. At least you asked 😛

---

<div class="post-metadata">

### Author: ![grey0ut](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/grey0ut/32/5310_2.png) [@grey0ut](https://forums.powershell.org/u/grey0ut)
#### Post date: [March 24, 2025, 6:26am UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/9 "2025-03-24T06:26:02Z")

</div>

I spent longer on it than I intended but my first draft of a Wake-on-LAN module that’s compatible with Desktop and Core editions as well as cross platform is up.  
[PSWoL](https://github.com/grey0ut/PSWoL)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)
#### Post date: [April 23, 2025, 6:26am UTC](https://forums.powershell.org/t/trying-to-use-wakeonlan-and-keep-getting-errors/25610/10 "2025-04-23T06:26:08Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
