Wednesday, 21 October 2009

Get-DNSInfo.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script re-implements a MSDN Sample in PowerShell that 
  4.    shows the use of System.Net.NetworkInformation.NetworkInterface 
  5. .DESCRIPTION 
  6.     This script gets network information and formats DNS info. The 
  7.     script is effectively a one-liner! 
  8. .NOTES 
  9.     File Name  : Get-DNSInfo.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15.     MSDN Sample posted at: 
  16.         http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getallnetworkinterfaces.aspx 
  17. .EXAMPLE 
  18.     PSH [C:\foo]: . 'E:\PowerShellScriptLib\System.Net.NetworkInformation\Get-DNSInfo.ps1' 
  19.  
  20.     DnsSuffix   IsDnsEnabled IsDynamicDnsEnabled 
  21.     ---------   ------------ ------------------- 
  22.     cookham.net        False                True 
  23.     cookham.net        False                True 
  24.                        False                True 
  25.     cookham.net        False                True 
  26. #> 
  27.   
  28. ## 
  29. # Start of script 
  30. ## 
  31.  
  32. #Get information and print - do this as a 1-liner! 
  33. [System.Net.Networkinformation.NetworkInterface]::GetAllNetworkInterfaces() | %{$_.GetIpProperties()} | FT Dnssuffix,Isdnsenabled,IsDynamicDnsEnabled -a 
  34. # End of script 

No comments: