Katz
Katz

Reputation: 866

How to join a strings in Powershell

I have a text file containing websites

whatsmyip
stackoverflow

and I want to join each line with .com at the end of each site. What is the best way to accomplish this? I set a variable called $sites and on that variable I called the .txt file into the script with get-content I tried doing a foreach loop to join the two text but my syntax isn't working. Any suggestions?.

foreach ( $website in $site  ) {
 $website -join ".com"
}

Upvotes: 0

Views: 79

Answers (1)

Kory Gill
Kory Gill

Reputation: 7153

You can use "$website.com" to create the string.

Upvotes: 3

Related Questions