Pls help.. How to add powershell script to resolve IP address DNS entry

Hi All,

Im having hardtime completing the attached script.

How to use the RESOLVE-DNSNAME to resolve the IP.

Sample outoupt and script is attached

 

OUTPUT:

ComputerName	IPAddress	MACAddress	Description	SubnetMask				IP DNS entry
SVR000953	100.168.20.109	00:50:xx:xx:69:55	vmxnet3 Ethernet Adapter	255.255.252.0
SVR000953	100.11.36.5	00:11:56:xx:6C:55	vmxnet3 Ethernet Adapter #6	255.255.224.0


PS script:

 #---------------------------------------------------------------------
        # Collect network interface information and convert to HTML fragment
        #---------------------------------------------------------------------    

        $subhead = "<h3>Network Interface Information</h3>"
        $htmlbody += $subhead

        Write-Verbose "Collecting network interface information"
        try
       { 

foreach ($Computer in $ComputerName) { 
 if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) { 
  try { 
$nics = @()
   $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $ComputerName -EA Stop | Where-Object {$_.IPEnabled}
  } catch { 
       Write-Warning "Error occurred while querying $computer." 
       Continue 
  } 
  foreach ($Network in $Networks) {
  $IPAddress  = $Network.IpAddress[0]
   $MACAddress  = $Network.MACAddress
   $SubnetMask  = $Network.IPSubnet[0]
   $Description = $Network.Description
   $IsDHCPEnabled = $false
   If($network.DHCPEnabled) {
    $IsDHCPEnabled = $true
   }
   $OutputObj  = New-Object -Type PSObject
   $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $ComputerName.ToUpper()
   $OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
   $OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress
   $OutputObj | Add-Member -MemberType NoteProperty -Name Description -Value $Description
   $OutputObj | Add-Member -MemberType NoteProperty -Name SubnetMask -Value $SubnetMask
   $OutputObj

   $nics +=$OutputObj
  } 
 } 
}

$htmlbody += $nics | ConvertTo-Html -Fragment
            $htmlbody += $spacer
        }
        catch
        {
            Write-Warning $_.Exception.Message
            $htmlbody += "<p>An error was encountered. $($_.Exception.Message)</p>"
            $htmlbody += $spacer
        }
		

Parents
  • instructions unclear. you might try adding these lines

    this after line 34

    $IpDnsEntry = resolve-dnsname $computername

    and this one after line 44 

    $OutputObj | Add-Member -MemberType NoteProperty -Name IpDnsEntry -Value $IpDnsEntry

  • thanks for your reply,

    I tried your suggestion but no success.. 

    What im trying to do here is to resolved the IP address of single server with multiple NICs.

    The attached scritp can only get the IP's of the multiple NICs but cannot resolve-dnsname the IP's.

    Once resolved the output showed appear in column under IP DNS Entry. 

Reply
  • thanks for your reply,

    I tried your suggestion but no success.. 

    What im trying to do here is to resolved the IP address of single server with multiple NICs.

    The attached scritp can only get the IP's of the multiple NICs but cannot resolve-dnsname the IP's.

    Once resolved the output showed appear in column under IP DNS Entry. 

Children
No Data