Question: I'm trying to extract some parameters from a list whose the structure and the length are variable. Basically, these parameters are the departure and the arrival addresses for a route. This list is built from a sentence in natural language so it does not follow any particular template: 

```
1st example : ['go', 'Buzenval', 'from', 'Chatelet']
2nd example : ['How', 'go', 'street', 'Saint', 'Augustin', 'from', 'Buzenval']
3rd example : ['go', 'from', '33', 'street', 'Republique', 'to', '12','street','Napoleon']

```

I already managed to create another list that is pretty much similar, for each case, except the departure and arrival are replaced by the actual words 'departure' and 'arrival'. With the examples above I obtain:

```
1st example : ['go', 'arrival', 'from', 'departure']
2nd example : ['How', 'go', 'arrival', 'from', 'departure']
3rd example : ['go', 'from', 'departure', 'to', 'arrival']

```

Now that I have these two kind of lists, I would like to identify departure and arrival : 

```
1rst example : departure = ['Chatelet'], arrival = ['Buzenval']
2nd example : departure =  ['Buzenval'], arrival = ['street','Saint','Augustin']
3rd example : departure = ['33','street','Republique'], arrival = ['12','street','Napoleon']

```

Basically, the parameters are everything that are different in the two lists, but I need to identify which one is the departure and which one is the arrival. I think Regex could help me on this one but I don't know how. 

Thanks for your help!

Answer: 
If you want to use SFTP I am using the code below to upload some files automatically to an ftp site:

First of all you have to download the winscp SFTP powershell libraries.
<https://winscp.net/eng/download.php>
then extract the contents at the same location the script is located.

Then in your script you must add:

```
# Load WinSCP .NET assembly
# Give the path the dll file is located so powershell can call it.
Add-Type -Path "C:\Path where the dll file is located\WinSCPnet.dll"

# Setup session options
# Add all the properties the session needs to be established such as username password hostname and fingerprint.
# The username and password must be in plaintext.
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "HostName"
    UserName = "UserName"
    Password = "Password"
    SshHostKeyFingerprint = "SSH fingerprint"

```

Then after the session with those credentials is up you must put your next step of copying the files.

```
# Open a session to the Host
# Try to connect to the Host with the credentials and information provided previously.
# Upload the file from a specific path to the path on the host.
# And then close the session and clean up the session trace data.
# $session.Dispose() -> If session was opened, closes it, terminates underlying WinSCP process, deletes XML log file and disposes object.
$session = New-Object WinSCP.Session

Try
{
   # Connect to the SFTP site
    $session.Open($sessionOptions)

   # Upload the files from local disk to the destination
    $session.PutFiles("Path of the file you want to upload", "/import/").Check()
}
Finally
{
   # Disconnect, clean up
   $session.Dispose()
}

```

Probably there is an easier way with Power Shell 6 that can do more with the Unix/Linux operating systems but at this point of answering I haven't used it.
Once you get Posh-SSH installed, something like this will probably get you down the road. There are ways to keep the password in plain text out of your script.

```
$SecurePassword = ConvertTo-SecureString -AsPlainText 'thepassword' -Force
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'me',$SecurePassword

$Session = New-SFTPSession -ComputerName 'zenith' -Credential $Credentials -ConnectionTimeout 30
$r = Set-SFTPFile -Session $Session. -LocalFile 'C:\Users\me\t.txt' -RemotePath '/home/me' -Overwrite
Remove-SFTPSession -SFTPSession $session | Out-Null

```