Retreive Network Adapter Settings


posted by tonys
03-10-2010

Downloads: 676
File size: 4.6kB
Views: 3,225

Embed
Retreive Network Adapter Settings
  1. ######################################################################## 
  2. # Created by Tony Sangha 11/03/2010 
  3. # Objective: Retreive Network Adapter settings for Windows Host Machines 
  4. ######################################################################## 
  5. # Account that runs script must have local administrator on remote machines 
  6. # Excel must be installed on machine where script is being run 
  7.  
  8.  
  9. # Change path to a text file which contains names of machines you wish to query 
  10. $server = gc c:\scripts\Win2k8Servers.txt 
  11.  
  12. # Create Excel Spreadsheet and format 
  13. $Excel = New-Object -Com Excel.Application 
  14. $Excel.visible = $True 
  15. $Excel = $Excel.Workbooks.Add() 
  16.  
  17. $Sheet = $Excel.WorkSheets.Item(1) 
  18. $Sheet.Cells.Item(1,1) = “Server Name” 
  19. $Sheet.Cells.Item(1,2) = “DNS Name” 
  20. $Sheet.Cells.Item(1,3) = “DNS Domain” 
  21. $Sheet.Cells.Item(1,4) = “IP Address v4 & v6” 
  22. $Sheet.Cells.Item(1,5) = “Subnet Mask” 
  23. $Sheet.Cells.Item(1,6) = “Default Gateway” 
  24. $Sheet.Cells.Item(1,7) = “MAC Address” 
  25. $Sheet.Cells.Item(1,8) = “DNS Domain Suffix Available” 
  26. $Sheet.Cells.Item(1,9) = “DHCP Server” 
  27. $Sheet.Cells.Item(1,10) = “WINS Server Primary” 
  28. $Sheet.Cells.Item(1,11) = “WINS Server Secondary” 
  29. $Sheet.Cells.Item(1,12) = “DNS Servers” 
  30.  
  31. $WorkBook = $Sheet.UsedRange 
  32. $WorkBook.Interior.ColorIndex =
  33. $WorkBook.Font.ColorIndex = 11 
  34. $WorkBook.Font.Bold = $True 
  35.  
  36. $intRow =
  37.  
  38. # Retreive Info for each machine and populate Excel Spreadsheet 
  39.  
  40. foreach ($s in $server
  41. $colItems = Get-wmiObject Win32_networkadapterconfiguration -computername $s | Where-Object{$_.IPENabled -eq "True"
  42.  
  43. foreach ($objItem in $colItems) { 
  44. $Sheet.Cells.Item($intRow,1) = $s 
  45. $Sheet.Cells.Item($intRow,2) = $objItem.DNSHostName 
  46. $Sheet.Cells.Item($intRow,3) = $objItem.DNSDomain 
  47. $Sheet.Cells.Item($intRow,4) = $objItem.IPAddress 
  48. $Sheet.Cells.Item($intRow,5) = $objItem.IPSubnet 
  49. $Sheet.Cells.Item($intRow,6) = $objItem.DefaultIPGateway 
  50. $Sheet.Cells.Item($intRow,7) = $objItem.MACAddress 
  51. $Sheet.Cells.Item($intRow,8) = $objItem.DNSDomainSuffixSearchOrder 
  52. $Sheet.Cells.Item($intRow,9) = $objItem.DHCPServer 
  53. $Sheet.Cells.Item($intRow,10) = $objItem.WINSPrimaryServer 
  54. $Sheet.Cells.Item($intRow,11) = $objItem.WINSSecondaryServer 
  55. $Sheet.Cells.Item($intRow,12) = $objItem.DNSServerSearchOrder 
  56.  
  57. $intRow = $intRow +
  58.  
  59. $WorkBook.EntireColumn.AutoFit() 
  60. Clear 

This script will retreive network adapter settings for windows host machines and create an Excel Spreadsheet with the information.

Pre-req

  1. Text file with server names
  2. Excel installed locally
  3. Local Admin rights on remote hosts

 

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.