This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathClear-ARPCache.ps1
49 lines (39 loc) · 1.48 KB
/
Clear-ARPCache.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
###############################################################################################################
# Language : PowerShell 4.0
# Filename : Clear-ARPCache.ps1
# Autor : BornToBeRoot (https://github.com/BornToBeRoot)
# Description : Clear the ARP cache
# Repository : https://github.com/BornToBeRoot/PowerShell
###############################################################################################################
<#
.SYNOPSIS
Clear the ARP cache
.DESCRIPTION
Clear the Address Resolution Protocol (ARP) cache, which is used for resolution of internet layer addresses into link layer addresses.
.EXAMPLE
Clear-ARPCache
.LINK
https://github.com/BornToBeRoot/PowerShell/blob/master/Documentation/Function/Clear-ARPCache.README.md
#>
function Clear-ARPCache
{
[CmdletBinding()]
param(
)
Begin{
if(-not([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator"))
{
Write-Warning -Message "Administrator rights are required to clear the ARP cache! Attempts to start the process with elevated privileges..."
}
}
Process{
try{
Start-Process -FilePath "$env:SystemRoot\System32\netsh.exe" -ArgumentList "interface ip delete arpcache" -Verb "RunAs" -WindowStyle Hidden -Wait
}
catch{
throw
}
}
End{
}
}