Soldato
Wonder if you guys can assist with something.
I am writing a script to download 6 files from 3 different FTP locations which can easily be done by doing 3 different downloads but this increases the code (Negligible I know but I prefer doing things in more concise ways)
Now I am trying to get it to build the powershell for me using a foreach loop.
So the basics I have are as follows
FYI LogOutPut Is a function we have that prints whatever we put in "" and catches any red errors etc
This obviously prints each of the regions as expected. Now the next thing I wanted to do was to build the UK\US\PT file variable name using the $R variable I.E
But this does not work. It prints the variable correctly but not the contents of this variable. There has to be a way to do this but as it is Friday and it has been a long week I cannot get my head around it.
I am writing a script to download 6 files from 3 different FTP locations which can easily be done by doing 3 different downloads but this increases the code (Negligible I know but I prefer doing things in more concise ways)
Now I am trying to get it to build the powershell for me using a foreach loop.
So the basics I have are as follows
FYI LogOutPut Is a function we have that prints whatever we put in "" and catches any red errors etc
PHP:
$DLRegion = @("US","PT","UK")
$PTFiles =@("File1","File2")
$USFiles =@("File3","File4")
$UKFIles =@("File5","Files6")
FOREACH($R in $DLREGION)
{
If ($exitcode -eq 0)
{
Start-Sleep 1
LogOutput "Start $R FTP process"
}
}
This obviously prints each of the regions as expected. Now the next thing I wanted to do was to build the UK\US\PT file variable name using the $R variable I.E
PHP:
FOREACH($R in $DLREGION)
{
If ($exitcode -eq 0)
{
Start-Sleep 1
LogOutput "Start $R FTP process"
FOREACH($F in "$R`Files")
{
LogOutPut $F
}
}
}
But this does not work. It prints the variable correctly but not the contents of this variable. There has to be a way to do this but as it is Friday and it has been a long week I cannot get my head around it.