Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

add text to the end of a string

$
0
0

I have a .txt file that has hundreds of machine names.  one per line.   I need to add our domain name to the end of each machine.

from:  PC01234

to:     PC01234.Acme.com

I've tried the Add-Content but it did not work.

get-content "C:\Temp\3.txt" | foreach-object {add-content C:\temp\3.txt "$_ .Acme.org"}

It either does not work or it adds a space in-between the end of the computer and the period. 

Is add-content the wrong choice for this task? 


Viewing all articles
Browse latest Browse all 6937

Trending Articles