I have two arrays that contain a selection of lines with information taken from a text file. Then I use the For Loop loop to loop through both arrays and print the lines together to create the destination folder and file name.
Get-Content .\PostBackupCheck-TextFile.txt | ForEach-Object { $a = $_ -split ' ' ; $locationArray += "$($a[0]):\$($a[1])\" ; $imageArray += "$($a[2])_$($a[3])_VOL_b00$($a[4])_i000.spi" }
The above text contains a text file, splits it into separate parts, saves some in locationArray and other information in imageArray , for example:
locationArray[0] will be L:\Place\
imageArray[0] will be SERVERNAME_C_VOL_b001_i005.spi
Then I run the for loop:
for ($i=0; $i -le $imageArray.Length - 1; $i++) {Write-Host $locationArray[$i]$imageArray[$i]}
But it puts a space between L:\Place\ and SERVERNAME_C_VOL_b001_i005.spi
So it becomes: L:\Place\ SERVERNAME_C_VOL_b001_i005.spi
Instead, it should be: L:\Place\SERVERNAME_C_VOL_b001_i005.spi
How can i fix this?
source share