SHOW:
|
|
- or go back to the newest paste.
| 1 | Function Get-DNSConfig {
| |
| 2 | param ([string]$StrComputer=$Env:COMPUTERNAME) | |
| 3 | ||
| 4 | $ServerProps = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 'True'" -ComputerName $StrComputer | Select @{Name="ServerName"; Expression={"$StrComputer"}},DNSHostName, Index
| |
| 5 | ||
| 6 | Foreach ($server in $ServerProps) | |
| 7 | {
| |
| 8 | $out = $null | |
| 9 | $out = New-Object PSObject | |
| 10 | ||
| 11 | $Dnslist = @(Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 'True'" -ComputerName $StrComputer | Where {$_.Index -eq $server.index} | Select -ExpandProperty DNSServerSearchOrder)
| |
| 12 | - | $Dnslist = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 'True'" -ComputerName $StrComputer ` | Where {$_.Index -eq $server.index} | Select -ExpandProperty DNSServerSearchOrder
|
| 12 | + | |
| 13 | - | #$Dnslist = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 'True'" -ComputerName $StrComputer ` | Select -ExpandProperty DNSServerSearchOrder |
| 13 | + | $out = New-Object PSObject -Property @{
|
| 14 | ServerName = $($server.Servername) | |
| 15 | - | Write-Output "Echoing $dnslist" |
| 15 | + | DNSHostName = $($server.DNSHostName) |
| 16 | Index = $($server.Index) | |
| 17 | - | $DNSServer1 = $null |
| 17 | + | DNS1 = $($Dnslist[0]) |
| 18 | - | $DNSServer2 = $null |
| 18 | + | DNS2 = $($Dnslist[1]) |
| 19 | - | $DNSServer3 = $null |
| 19 | + | DNS3 = $($Dnslist[2]) |
| 20 | - | $DNSServer4 = $null |
| 20 | + | DNS4 = $($Dnslist[3]) |
| 21 | - | $DNSServer5 = $null |
| 21 | + | DNS5 = $($Dnslist[4]) |
| 22 | } ## End Object | |
| 23 | - | $DNSServer1 = $Dnslist[0] |
| 23 | + | |
| 24 | - | $DNSServer2 = $Dnslist[1] |
| 24 | + | #$out |
| 25 | - | $DNSServer3 = $Dnslist[2] |
| 25 | + | $objreport+=@($out) |
| 26 | - | $DNSServer4 = $Dnslist[3] |
| 26 | + | |
| 27 | - | $DNSServer5 = $Dnslist[4] |
| 27 | + | |
| 28 | Return $objreport | |
| 29 | - | $out | Add-Member noteproperty ServerName $($Server.ServerName) |
| 29 | + | } ## End Function Get-DNSConfig |