How to validate a MAC address in Powershell

I’ve updated my OHTools module (See here for more info and how to use it) so that it now includes a MAC validation function.  You can validate a MAC address and also change the delimiter.

So for example, if a user enters a MAC of 12:12:12:12:12:12 and you need the MAC not only validated but to have the delimiter as a ‘-‘ or even remove the delimiter entirely, then you can do so very easily now.

It’s as easy as: Validate-OHMacAddress “12:12:12:12:12:12” -delimiter “-“

This will produce the result of: 12-12-12-12-12-12

The function will return $FALSE if the MAC fails validation.

Download OHTools here.

Next up will be IP address validation.

Be the first to comment

Leave a Reply