• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

Script to list hostnames with a pipe symbol to separate


I have a list of about 500 servers in an excel spreadsheet that I need to enter into a particular format:


I don't want to enter the 500 server names manually followed by a pipe several hundred times..

Is there a way I can parse the list of server names so that it outputs like BWICTXD01|BWIZDCD01|BWILICD01)]

Thanks much

1 Solution
QlemoBatchelor and DeveloperCommented:
No clue what you are talking about ;-) What is input and output?
tobe1424Author Commented:
please excuse my lack of programming knowledge..

I have a list of 500 servers. As an example I am only using four.

the input would be a simple list..txt...docx..


I want the output to be this


thanks in advance

tobe1424Author Commented:
the output may also go into a txt file.

It sounds simple. But being a newb programmer, this is currently over the top of my head
WEBINAR: GDPR Implemented - Tips & Lessons Learned

Join the WatchGuard team on Thursday, March 29th as we recount some valuable lessons learned in weighing the needs of a business against the new regulatory environment, look ahead at the two months left before implementation, and help you understand the steps you can take today!

Justin YeungSenior Systems EngineerCommented:
Get-Content c:\name.txt | % {$All += $_ + " | "}

Open in new window

The result will be "Host1 | Host2 | Host3 | Host4 |"
I think the input file is excel.
Instead of 4 per your example, you want one long string of 500?
tobe1424Author Commented:
Thanks Justin. I will give that a try right away.

NewVillage, Yes the file is in excel, but I can transfer the entire column to text only on a word/txt file which i will try to point to per justins instructions
tobe1424Author Commented:
Thanks a bunch justin !!! that worked flawlessly.

i had an issues executing the .ps1

cannot be loaded because the execution of scripts is disabled on this system.

But i ran this below and all worked fine afterwards

I have ran set-executionpolicy unrestricted


Justin YeungSenior Systems EngineerCommented:
no problem and happy new year
tobe1424Author Commented:
likewise J !
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

We Need Your Input!

WatchGuard is currently running a beta program for our new macOS Host Sensor for our Threat Detection and Response service. We're looking for more macOS users to help provide insight and feedback to help us make the product even better. Please sign up for our beta program today!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now