Nslookup PS Script help

Welcome Forums General PowerShell Q&A Nslookup PS Script help

This topic contains 2 replies, has 3 voices, and was last updated by

1 year, 3 months ago.

  • Author
  • #83314

    Points: 6
    Rank: Member

    Dear Community

    I have requirement to find out which database servers are my servers connected to . I do not have access to query SQL PS commands hence i come up with below script to query from server that i connected. The script is bit ok but i wanted to check with you all 🙂 to see if there is any other better way i can do this .

    $cmd = netstat -ano | findstr ":1433"
    $cmd = $cmd.split(10)
    $result = $cmd[10]
    $result = $result.replace(":1433", "")
    $DBServer = nslookup $result 
    $DBServer = $DBServer | select-string "Name"
    write-host "Server connected to $DBServer"
  • #83380

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Not really. If it works, it's great, right? 🙂

  • #83413

    Points: 521
    Helping Hand
    Rank: Major Contributor

    Actually there is a powershell version of netstat:

    Get-NetTCPConnection | where remoteport -eq 1433 | select -expand remoteaddress -first 1 | Resolve-DnsName

The topic ‘Nslookup PS Script help’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort