Hi All,
I am trying to get NIC settings from list of windows servers along with NIC label "NetConnectionID " and DNS suffer list, but unable to accommodate them in excel output , kindly help , below is the script
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$Sheet1 = $Excel.Worksheets.Item(1)
$Sheet1.Name = "Network"
$Sheet1.Cells.Item(1,1) = "Server_Name"
$Sheet1.Cells.Item(1,2) = "DHCP_Enabled"
$Sheet1.Cells.Item(1,3) = "IP_Address"
$Sheet1.Cells.Item(1,4) = "Subnet_Mask"
$Sheet1.Cells.Item(1,5) = "Default_Gateway"
$Sheet1.Cells.Item(1,6) = "DNS_Servers"
$Sheet1.Cells.Item(1,7) = "DNS_Reg"
$Sheet1.Cells.Item(1,8) = "Primary_WINS"
$Sheet1.Cells.Item(1,9) = "Secondary_WINS"
$Sheet1.Cells.Item(1,10) = "WINS_Lookup"
$Sheet1.Cells.Item(1,11) = "NIC lable"
$intRowNet = 2
$colSheets = ($Sheet1)
foreach ($colorItem in $colSheets){
$intRow = 2
$intRowNet = 2
$WorkBook = $colorItem.UsedRange
$WorkBook.Interior.ColorIndex = 4
$WorkBook.Font.ColorIndex = 11
$WorkBook.Font.Bold = $True
}
foreach ($colorItem in $colSheets){
$WorkBook = $colorItem.UsedRange
$WorkBook.EntireColumn.AutoFit()
cls
}
$Computers = Get-Content .\Servers.txt
Foreach ($Computer in $Computers) {
$NetItems = gwmi Win32_NetworkAdapterConfiguration -ComputerName $Computer -ErrorAction Ignore | ?{$_.IPEnabled -eq "True"}
$NetItems1 = gwmi Win32_NetworkAdapter -ComputerName $Computer
foreach ($objItem3 in $NetItems) {
$Sheet1.Cells.Item($intRowNet,
1) = $Computer
$Sheet1.Cells.Item($intRowNet,
2) = $objItem3.DHCPEnabled
$Sheet1.Cells.Item($intRowNet,
3) = $objItem3.IPAddress
$Sheet1.Cells.Item($intRowNet,
4) = $objItem3.IPSubnet
$Sheet1.Cells.Item($intRowNet,
5) = $objItem3.DefaultIPGateway
$Sheet1.Cells.Item($intRowNet,
6) = $objItem3.DNSServerSearchOrder
$Sheet1.Cells.Item($intRowNet,
7) = $objItem3.FullDNSRegistrationEnabled
$Sheet1.Cells.Item($intRowNet,
8) = $objItem3.WINSPrimaryServer
$Sheet1.Cells.Item($intRowNet,
9) = $objItem3.WINSSecondaryServer
$Sheet1.Cells.Item($intRowNet,
10) = $objItem3.WINSEnableLMHostsLookup
$NetItems1 | Select-Object -ExpandProperty NetConnectionID
| select {$Lable = $_;$Lable;$Sheet1.Cells.Item($intRowNet, 11) = $Lable ;}
$intRowNet = $intRowNet + 1
}
$intRowNet = $intRowNet + 1
}