About Me

My photo
HANUMANGARH, RAJASTHAN, India

Thursday, 23 July 2020

Get Multiple NSLOOKUP status in powershell

$servers = get-content C:\Users\sunil\Desktop\allservers.txt
foreach ($Server in $Servers)
{

    $Addresses = $null
    try {
        $Addresses = [System.Net.Dns]::GetHostAddresses("$Server").IPAddressToString
    }
    catch { 
        $Addresses = "Server IP cannot resolve."
    }
    foreach($Address in $addresses) {
        write-host $Server, $Address 
    }
}

No comments:

Post a Comment

Extract Disk Info from Remote host

 # Define the remote hostname or IP address $remoteHost = Get-Content "C:\temp\RemoteServer.txt" # Define the output CSV file path...