<# .SYNOPSIS Restart all physical network adapters .DESCRIPTION If run with elevated privileges, this script will disable all physical network adapters on the local computer, wait for a specified number of seconds (default: 5), and then reenable all physical network adapters. If run without elevated privileges, this script will only show each physical network adapter's status. .PARAMETER Delay The number of seconds between disabling/enabling the network card and checking the new status. .PARAMETER Version Show this script's version number. If combined with -Verbose show full script path, version number and last/modified/release date. .PARAMETER Verbose Show verbose version info when -Version switch is used. .EXAMPLE . './Restart_PhysicalNetworkAdapters.ps1' Output will look like this: Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- Ethernet NVIDIA nForce Networking Controller 6 Up 01-23-45-67-89-AB 1 Gbps Ethernet NVIDIA nForce Networking Controller 6 Disabled 01-23-45-67-89-AB 1 Gbps Ethernet NVIDIA nForce Networking Controller 6 Up 01-23-45-67-89-AB 1 Gbps .LINK Script written by Rob van der Woude https://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 } Get-NetAdapter -Physical if ( ( [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent( ) ).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ) ) { Get-NetAdapter -Physical | Disable-NetAdapter -AsJob | Out-Null Start-Sleep $Delay Get-NetAdapter -Physical Get-NetAdapter -Physical | Enable-NetAdapter -AsJob | Out-Null Start-Sleep $Delay Get-NetAdapter -Physical }