Hi,
I made a script in PowerShell and I need your help.
####################################################
clear
$A1=“line1”
$A2=“line2”
$A3=“line3”
$fields= “A1”,“A2”,“A3”
ForEach ($ligne in $($fields))
{
$ligne+“;”
}
####################################################
When I execute the script, it display A1; A2; A3;
But I want the result of the fields like that : line1; line2; line3;
While Rahul already showed you how to achieve what you wanted it looks like you’re trying to solve a bigger issue you’re not showing here yet. There might be a better way to achieve what you actually want to do in the end?!
Regardless of that: Could you please format your code as code here in the forum?
Thanks in advance.
This is an alternative to @Rahul20’s answer, which produces the same output; but it demonstrates the language flexibility in PowerShell. Like @Olaf, I am curious about the larger picture. Knowing the intentions for your program helps to assess the route to an accurate and efficient solution. If you are new to PowerShell, this forum can also recommend educational resources and practices for quicker learning.