Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

PowerShell Export to txt file not exporting IP

$
0
0

I am having an issue getting my IPs to export out to my txt file. The Hostname works fine but IPs are not there any suggestions?

$ErrorActionPreference = ‘SilentlyContinue’
get-content C:\computers.txt | foreach-object{
$a=([system.net.Dns]::GetHostAddresses($_)).IPAddressToString
if($? -eq $False) {add-content -path C:\computersips.txt -value "$_,Cannot resolve hostname"}
elseif($? -eq $True){add-content -path C:\computersips.txt -value "$_,$a"}
}


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>