Need help in a powershell script . My code
foreach($line in Get-Content C:UsersG661600Downloadssublist.txt) {
[System.Net.Dns]::GetHostAddresses(“$line”) | select IPAddressToString }
This gives me the IP addresses of domains contained in sublist.txt. Sublist.txt also contains some domains which donot resolve to any IP. If I redirect this output to a file it also contains the errors (for the domains which don’t resolve)
My query is
- How to get get the domain names against the IP addresses
- How to get only the output omitting the errors from the output file