Help with the script

Hello,
I need help with this script. IT is working great if I just use shortnames, but I also need to validate that IP addresses are correct using input with FQDN of servers. For example, server01.domain.com

Below, you can see the output that I get - it cuts off the full server name and it exports it with dots - .......
Is it possible to fix it so that in the output file the server names are not cut off. I need to get the entire server name in the output

Thank you very much.


$Computers = Get-Content C:\scripts\Computerlist.txt

Test-Connection $Computers | Out-File C:\scripts\pingresults.csv


$Computers = Get-Content C:\scripts\Computerlist.txt

Test-Connection $Computers | Out-File C:\scripts\pingresults.csv

Below is what the output looks like:
               
Source      Destination      IPV4Address      IPV6Address
------      -----------      -----------      -----------
       
USSRV-INFS...      USSRC-GNHRP9...      10.35.22.1       
USSRV-INFS...      USSRC-BGPRP9...      10.35.21.104       
creative555Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Never do that if you require proper formatting. You should create a real CSV:
Test-Connection (Get-Content C:\scripts\Computerlist.txt) -count 1 |
  select PsComputerName, Address, IPv4Address, IPv6Address, ResponseTime |
  Export-CSV -NoType C:\scripts\pingresults.csv

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
The reason is that PowerShell does some clever formatting if on screen, but fails if you try to write that formatted text into a file. You need to tell which fields you want to keep, and if using as text output, perform your formatting yourself. This is not shown in the code above.
creative555Author Commented:
THank you so much!! Perfect!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.