IT-Yogi

Flexibla lösningar!

Följ mig

twitterlinkedinby feather
You are here: Home / IT / Skript / Quickly set new DNS servers on a certain subnet

Quickly set new DNS servers on a certain subnet

November 6, 2013 by Lars Gustavsson Leave a Comment

A customer wanted to change and validate the DNS configuration on a subnet so I created this script.

PowerShell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Script that replaces or sets a random set of DNS servers on every networkadapter with a certain default gateway.
# Version 1.0
# Created by: Lars Gustavsson Knowledge Factory
 
# Creates two variables to randomly select between.
$0 = "10.0.10.10,10.0.10.11"
$1 = "10.0.10.11,10.0.10.10"
 
#Getting the IP configuration on all interfaces with a manually configured gateway.
$Interfaces = Get-NetIPConfiguration | Where-Object {$_.IPv4DefaultGateway.NextHop -eq "10.0.10.254" -and $_.IPv4Address.PrefixOrigin -eq "manual"}
 
#Looping through all the interfaces and setting the DNS servers.
foreach ($interface in $interfaces){
$DNS = Get-Random -InputObject $0, $1
Set-DnsClientServerAddress -InterfaceAlias $interface.InterfaceAlias -ServerAddresses $DNS
}

Intressant? Dela på:
twitterlinkedinby feather

Filed Under: Skript

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Ämnen

  • Health
  • IT
    • Skript
    • Solutions (English)

Senast skrivet

  • Protected: Video
  • Fitness, health and movement
  • Installera serverroller från xml del 2
  • Installera serverroller från xml
  • Quickly set new DNS servers on a certain subnet

Bloggegor

  • Fredrik Pålerud
  • Henrik Ericsson
  • Jimmy Andersson
  • Johan Arwidmark
  • Kim Hellman
  • Oscar Virot
  • Simon Wåhlin
  • Tobias Öien
  • Tomas Lepa

Arkiv

Recent Comments

  • Installera serverroller från xml del 2 | IT-Yogi on Automatiskt skapa websiter från CSV-fil
  • Installera serverroller från xml del 2 | IT-Yogi on Installera serverroller från xml
  • Remembers that casting variables is sticky | Tidbits of Information from Virot on Automatiskt skapa websiter från CSV-fil

Copyright © 2021 · BlogNews Theme on Genesis Framework · WordPress · Log in