If for whatever reason which you need to turn your network on and off oftenly in Windows, this PowerShell script may be able help you.
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
exit;
}
$nic = "Ethernet 2"
$adapter = Get-NetAdapter -Name $nic
if ($adapter.status -eq "Up") {
Disable-NetAdapter -name $nic -Confirm:$False
}
else {
Enable-NetAdapter -name $nic
}
# Read-Host -Prompt "Press any key to continue"
No comments:
Post a Comment