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



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

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"

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." 
  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

   $nics +=$OutputObj

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

  • 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.