Link to home
Start Free TrialLog in
Avatar of Robert Perez-Corona
Robert Perez-CoronaFlag for United States of America

asked on

Script to list hostnames with a pipe symbol to separate

Hello,

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

[host::(hostname1|hostname2|hostname3|hostname4)]


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

t
Avatar of Qlemo
Qlemo
Flag of Germany image

No clue what you are talking about ;-) What is input and output?
Avatar of Robert Perez-Corona

ASKER

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..

host1
host2
host3
host4


I want the output to be this

(host1|host2|host3|host4)


thanks in advance

t
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
ASKER CERTIFIED SOLUTION
Avatar of Justin Yeung
Justin Yeung
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think the input file is excel.
Instead of 4 per your example, you want one long string of 500?
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
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

cheers

t
no problem and happy new year
likewise J !