add pode and api scripts
This commit is contained in:
parent
30a3d7711e
commit
94bc297ea1
20 changed files with 783 additions and 3 deletions
52
Scripts/Get-ARP.psm1
Normal file
52
Scripts/Get-ARP.psm1
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
function Get-ARP {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Module using arp.exe for created object powershell and search mac-address
|
||||
For proxy use Invoke-Command via WinRM
|
||||
.DESCRIPTION
|
||||
Example:
|
||||
Get-MACProxy # default localhost
|
||||
Get-MACProxy -proxy dc-01 # remote get arp table
|
||||
Get-MACProxy -proxy dc-01 -search server-01 # search mac-address server on proxy-server
|
||||
.LINK
|
||||
https://github.com/Lifailon
|
||||
#>
|
||||
Param (
|
||||
$proxy,
|
||||
$search
|
||||
)
|
||||
if (!$proxy) {
|
||||
$arp = arp -a
|
||||
}
|
||||
if ($proxy) {
|
||||
$arp = icm $proxy {arp -a}
|
||||
}
|
||||
$mac = $arp[3..260]
|
||||
$mac = $mac -replace "^\s\s"
|
||||
$mac = $mac -replace "\s{1,50}"," "
|
||||
$mac_coll = New-Object System.Collections.Generic.List[System.Object]
|
||||
foreach ($m in $mac) {
|
||||
$smac = $m -split " "
|
||||
$mac_coll.Add([PSCustomObject]@{
|
||||
IP = $smac[0];
|
||||
MAC = $smac[1];
|
||||
Type = $smac[2]
|
||||
})
|
||||
}
|
||||
if ($search) {
|
||||
if ($search -NotMatch "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") {
|
||||
#$ns = nslookup $search
|
||||
#$ns = $ns[-2]
|
||||
#$global:ns = $ns -replace "Address:\s{1,10}"
|
||||
$rdns = Resolve-DnsName $search -ErrorAction Ignore
|
||||
$ns = $rdns.IPAddress
|
||||
if ($ns -eq $null) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
$ns = $search
|
||||
}
|
||||
$mac_coll = $mac_coll | ? ip -Match $ns
|
||||
}
|
||||
$mac_coll
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue