daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $dns1 = "192.168.1.4"
  2. $dns2 = "192.168.1.5"
  3. #-----------------------------------------------------------
  4. #i want to set the DNS for all adapters
  5. try{
  6.     $adapters = Get-NetAdapter -ErrorAction Stop
  7.     foreach($adapter in $adapters){
  8.         Set-DnsClientServerAddress -InterfaceAlias $adapter.InterfaceAlias -ServerAddresses $dns1, $dns2 | Out-Null
  9.     }
  10. }
  11. catch{
  12.     Write-Error $_
  13. }
  14. #-----------------------------------------------------------
  15. #i know the interface i want to set the adapter on
  16. Set-DnsClientServerAddress -InterfaceAlias PublicNetTeam -ServerAddresses $dns1, $dns2 | Out-Null
  17. #-----------------------------------------------------------
RAW Paste Data
Top