-
Notifications
You must be signed in to change notification settings - Fork 14
/
Get-CiscoMAC.ps1
72 lines (52 loc) · 1.79 KB
/
Get-CiscoMAC.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Function Get-CiscoMAC {
<#
.SYNOPSIS
This cmdlet is used to translate a MAC address into a grepable/include Cisco formatted MAC address
.DESCRIPTION
Convert a MAC address into a format that Cisco uses in its MAC Address table.
.PARAMETER MAC
Set the MAC address value you want converted to Cisco format
.EXAMPLE
Get-CiscoMAC -MAC ffffffffffff
# This example converts ffffffffffff to ffff.ffff.ffff
.EXAMPLE
Get-CiscoMAC -MAC ff-ff-ff-ff-ff-ff
# This example converts ff-ff-ff-ff-ff-ff to ffff.ffff.ffff
.EXAMPLE
Get-CiscoMAC -MAC ff.ff.ff.ff.ff.ff
# This example converts ff.ff.ff.ff.ff.ff to ffff.ffff.ffff
.EXAMPLE
Get-CiscoMAC -MAC ff:ff:ff:ff:ff:ff
# This example converts ff:ff:ff:ff:ff:ff to ffff.ffff.ffff
.NOTES
Author: Robert H. Osborne
Alias: tobor
Contact: [email protected]
.INPUTS
System.String
.OUTPUTS
System.String
.LINK
https://osbornepro.com
https://btpssecpack.osbornepro.com
https://writeups.osbornepro.com
https://github.com/OsbornePro
https://gitlab.com/tobor88
https://www.powershellgallery.com/profiles/tobor
https://www.hackthebox.eu/profile/52286
https://www.linkedin.com/in/roberthosborne/
https://www.credly.com/users/roberthosborne/badges
#>
[CmdletBinding()]
param(
[Parameter(
Position=0,
Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$False,
HelpMessage="Enter the MAC address you want to convert to Ciscos MAC format. `nEXAMLPE: ff:ff:ff:ff `nEXAMPLE:ffffffff `nEXAMPLE: ff.ff.ff.ff `nEXAMPLE: ff-ff-ff-ff")] # End Parameter
[String]$MAC) # End param
$Translate = $MAC.Replace(":","").Replace(".","").Replace("-","")
($Translate -Split '(....)' -ne '' -join '.').ToLower()
Return
} # End Function Get-CiscoMAC