-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetAdapterScript.ps1
45 lines (25 loc) · 950 Bytes
/
netAdapterScript.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
#Set-ExecutionPolicy RemoteSigned
$looping = $true
do{
Write-Host ('')
$adapterList = Get-NetAdapter -Name '*'
for($i=0; $i -lt $adapterList.Length; $i++)
{
write-host ([System.String]::Concat($i+1, ". ", $adapterList[$i].Name, ' -------> ', $adapterList[$i].Status, ' -------> ', $adapterList[$i].Speed) )
}
Write-Host ('')
$selection = Read-Host('Select a number to restart a network adapter, or press q/Q to quit.')
if($selection -notmatch "([Qq0-9])"){
Write-Host ('')
Write-Host ('**Bad input - Please select a number or press q/Q to quit, try again.**')
}elseif($selection -eq 'q' -or $selection -eq 'Q'){
Exit
}elseif($selection -in 1..$adapterList.Count){
$netObject = $adapterList[$selection-1]
Write-Host ('Restarting network adapter ' + $netObject.ifAlias)
Write-hOST "Working..."
Restart-NetAdapter -Name $netObject.ifAlias
Start-Sleep -s 5
}
}While($looping)