Monday, 30 April 2012

Show-DnsConfiguration.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script shows the DNS Configuration  of NICs  
  4.     in your system 
  5. .DESCRIPTION 
  6.     This script is a re-write of an MSDN Sample  
  7.     using PowerShell./ The script gets all network 
  8.     active network interfaces then prints out that 
  9.     interfaces' DNS Properties. 
  10. .NOTES 
  11.     File Name  : Show-DnsConfiguration.ps1 
  12.     Author     : Thomas Lee - tfl@psp.co.uk 
  13.     Requires   : PowerShell Version 2.0 
  14. .LINK 
  15.     This script posted to: 
  16.         http://www.pshscripts.blogspot.com 
  17.     MSDN sample posted to: 
  18.          http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getallnetworkinterfaces.aspx    
  19. .EXAMPLE 
  20.     Psh[C:\foo]> .\Show-DnsConfiguration.ps1 
  21.     Broadcom NetXtreme 57xx Gigabit Controller 
  22.       DNS suffix .............................. : cookham.net 
  23.       DNS enabled ............................. : False 
  24.       Dynamically configured DNS .............. : True 
  25.  
  26.     ... more interfaces snipped for brevity!     
  27. #> 
  28.  
  29. # Get the adapters than iterate over the collection and display DNS configuration 
  30. $adapters = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() 
  31. ForEach ($adapter in $adapters)   { 
  32.   $properties = $adapter.GetIPProperties() 
  33.   $adapter.Description 
  34.   "  DNS suffix .............................. : {0}" -f $properties.DnsSuffix 
  35.   "  DNS enabled ............................. : {0}" -f $properties.IsDnsEnabled 
  36.   "  Dynamically configured DNS .............. : {0}" -f $properties.IsDynamicDnsEnabled 

2 comments:

Kiquenet said...

it's great, fantastic blog.

Kiquenet said...

it's great, fantastic blog, thx