Add restart-network-adapters.ps1

This commit is contained in:
Markus Fleschutz 2021-08-27 15:00:49 +02:00
parent 0c3fc80a0d
commit 8735d0d6a5
3 changed files with 34 additions and 0 deletions

View File

@ -175,6 +175,7 @@ new-email.ps1, starts the default email client to write a new email
reboot.ps1, reboots the local computer (needs admin rights) reboot.ps1, reboots the local computer (needs admin rights)
reboot-fritzbox.ps1, reboots the FRITZ!box device reboot-fritzbox.ps1, reboots the FRITZ!box device
remove-empty-dirs.ps1, removes empty subfolders within the given directory tree remove-empty-dirs.ps1, removes empty subfolders within the given directory tree
restart-network-adapters.ps1, restarts all local network adapters
search-filename.ps1, searches the directory tree for filenames by given pattern search-filename.ps1, searches the directory tree for filenames by given pattern
search-files.ps1, searches the given pattern in the given files search-files.ps1, searches the given pattern in the given files
scan-ports.ps1, scans the network for open/closed ports scan-ports.ps1, scans the network for open/closed ports

Can't render this file because it has a wrong number of fields in line 84.

View File

@ -76,6 +76,7 @@ Mega Collection of PowerShell Scripts
* [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (needs admin rights) * [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (needs admin rights)
* [query-smart-data.ps1](Scripts/query-smart-data.ps1) - queries the S.M.A.R.T. data of your HDD/SSD's * [query-smart-data.ps1](Scripts/query-smart-data.ps1) - queries the S.M.A.R.T. data of your HDD/SSD's
* [reboot.ps1](Scripts/reboot.ps1) - reboots the local computer (needs admin rights) * [reboot.ps1](Scripts/reboot.ps1) - reboots the local computer (needs admin rights)
* [restart-network-adapters.ps1](Scripts/restart-network-adapters.ps1) - restarts all local network adapters
* [upgrade-ubuntu.ps1](Scripts/upgrade-ubuntu.ps1) - upgrades Ubuntu Linux to the latest (LTS) release * [upgrade-ubuntu.ps1](Scripts/upgrade-ubuntu.ps1) - upgrades Ubuntu Linux to the latest (LTS) release
* [wakeup.ps1](Scripts/wakeup.ps1) - sends a magic packet to the given computer, waking him up * [wakeup.ps1](Scripts/wakeup.ps1) - sends a magic packet to the given computer, waking him up

View File

@ -0,0 +1,32 @@
#Requires -RunAsAdministrator
<#
.SYNOPSIS
restart-network-adapters.ps1
.DESCRIPTION
Restarts all local network adapters (needs admin rights)
.INPUTS
None
.OUTPUTS
None
.EXAMPLE
PS> .\restart-network-adapters.ps1
.LINK
htts://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz
Creation Date: 2021-08-27
License: CC0
#>
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
Get-NetAdapter | Restart-NetAdapter
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ restarted all local network adapters in $Elapsed sec"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}