Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Script to list hostnames with a pipe symbol to separate

Posted on 2014-12-26
Medium Priority
Last Modified: 2014-12-27

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

Question by:tobe1424
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 71

Expert Comment

ID: 40519082
No clue what you are talking about ;-) What is input and output?

Author Comment

ID: 40519142
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


Author Comment

ID: 40519159
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 14

Accepted Solution

Justin Yeung earned 2000 total points
ID: 40519164
Get-Content c:\name.txt | % {$All += $_ + " | "}

Open in new window

The result will be "Host1 | Host2 | Host3 | Host4 |"
LVL 25

Expert Comment

ID: 40519166
I think the input file is excel.
Instead of 4 per your example, you want one long string of 500?

Author Comment

ID: 40519189
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

Author Comment

ID: 40519220
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


LVL 14

Expert Comment

by:Justin Yeung
ID: 40519230
no problem and happy new year

Author Comment

ID: 40519685
likewise J !

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question