OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to redirect only the powershell output without errors to a file

  • Thread starter Thread starter Biswa
  • Start date Start date
B

Biswa

Guest
Need help in a powershell script . My code

foreach($line in Get-Content C:\Users\G661600\Downloads\sublist.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

  1. How to get get the domain names against the IP addresses
  2. How to get only the output omitting the errors from the output file
<p>Need help in a powershell script . My code</p>
<p>foreach($line in Get-Content C:\Users\G661600\Downloads\sublist.txt) {
[System.Net.Dns]::GetHostAddresses("$line") | select IPAddressToString }</p>
<p>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)</p>
<p>My query is</p>
<ol>
<li>How to get get the domain names against the IP addresses</li>
<li>How to get only the output omitting the errors from the output file</li>
</ol>
Continue reading...
 

Latest posts

Top