Extracting and printing the first 3 octets of a MAC using powershell
<pre><code>if($ping)
    {
        ( $mac | ? { $_ -match $ip } ) -match "([0-9A-F]{2}([:-][0-9A-F]{2}){5})" | out-null;
        if ( $matches ) {
            Select-String -Pattern '[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}' -Path $matches[0] |
            ForEach-Object {$_.Matches[0].Value}
        } else {
            "Not Found"
        }
    }
</code></pre>

<p>Is what I am currently using. Not sure if I am doing this right in PowerShell.</p>

<p>I am trying to Extract the first 3 XX:XX:XX of a MAC so that I can use it for a compare. I'm just not sure how pull after the match. </p>