(view source code of restart_ethernet.ps as plain text)
<#.SYNOPSISRestart Ethernet network adapter.DESCRIPTIONIf run with elevated privileges, this script will disable the Ethernet network adapter on the local computer, wait for a specified number of seconds (default: 5), and then reenable the Ethernet network adapter; before and after each step the Ethernet network adapter's status is shown.If run without elevated privileges, this script will only show the Ethernet network adapter's status..PARAMETER DelayThe number of seconds between disabling/enabling the network card and checking the new status.PARAMETER VersionShow this script's version number.If combined with -Verbose show full script path, version number and last/modified/release date..PARAMETER VerboseShow verbose version info when -Version switch is used..EXAMPLE. './Restart_Ethernet.ps1'If run with elevated privileges, output will look like this:Ethernet adapter status: UpEthernet adapter status: DisabledEthernet adapter status: UpIf run without elevated privileges, output will look like this:Ethernet adapter status: Up.LINKscript written by Rob van der Woudehttps://www.robvanderwoude.com/#>param(
[ValidateRange(5,60)]
[Int]$Delay = 5,
[switch]$Version,
[switch]$Verbose
)$progver = '1.01'
if ( $Version ) {
if ( $Verbose ) {
$lastmod = ( [System.IO.File]::GetLastWriteTime( $PSCommandPath ) )
if ( $lastmod.ToString( "h.mm" ) -eq $progver ) {
"`"{0}`", Version {1}, release date {2}" -f $PSCommandPath, $progver, $lastmod.ToString( "yyyy-MM-dd" )
} else {
# if last modified time is not equal to program version, the script has been tampered with"`"{0}`", Version {1}, last modified date {2}" -f $PSCommandPath, $progver, $lastmod.ToString( "yyyy-MM-dd" )
}} else {
$progver } exit 0}Write-Host ( "Ethernet adapter status: {0}" -f ( Get-NetAdapter -Name 'Ethernet' ).Status )
if ( ( [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent( ) ).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ) ) {
Write-Host "Disabling Ethernet adapter . . ."
Disable-NetAdapter -Name 'Ethernet' -AsJob | Out-Null
Start-Sleep $Delay
Write-Host ( "Ethernet adapter status: {0}" -f ( Get-NetAdapter -Name 'Ethernet' ).Status )
Write-Host "Enabling Ethernet adapter . . ."
Enable-NetAdapter -Name 'Ethernet' -AsJob | Out-Null
Start-Sleep $Delay
Write-Host ( "Ethernet adapter status: {0}" -f ( Get-NetAdapter -Name 'Ethernet' ).Status )
}page last modified: 2025-10-11; loaded in 0.0088 seconds