shchuko

script32.ps1

Feb 18th, 2020
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # script32.ps1
  2. $Answer = Read-Host "Enter mode (Auto/Manual)"
  3.  
  4. switch ($Answer) {
  5.     "Auto" {  
  6.         Remove-NetRoute -InterfaceAlias "Ethernet" -Confirm:$false
  7.         Set-NetIPInterface -InterfaceAlias "Ethernet" -Dhcp Enabled
  8.         Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ResetServerAddresses
  9.     }
  10.     "Manual" {
  11.         New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.1.10 -DefaultGateway 192.168.1.1 -PrefixLength 24
  12.         Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 8.8.8.8
  13.     }
  14.     Default {
  15.         Write-Host "Wrong input!"
  16.     }
  17. }
  18.  
  19. Pause
Add Comment
Please, Sign In to add comment