I have a text file (file1.txt) with records in different lines
Variable1,2018
Variable2,Jun
Now in my script I would like to store the values in different variables. Example, I would like my end result to be Year=2018 Period=Jun
I tried the below logic but it is not solving the purpose as it is storing both values in a single variable.
Get-Content "file1.txt" | ForEach-Object {
$Var=$_.split(",")
$Year=$Var[1]
$Period=$Var[1]
}
Please help.
file1.txt.