Foreach issues - only treating last domain on list

Hi Powershell!

I am working on trying to make a Powershell / WinSCP script that can do the following:

Consider a list of domains

Delete a list of the same files, from each of these domains

Upload new data to another location on these same domains.

It sort of works by now, but, for some reason my foreach loop does not seem to quite get me.
It seems to be only taking the last domain on the list, which is

The ouput (written to host) is:

Removing of file* succeeded
Removing of file* succeeded
Uploading to C:\Users\Dern\Desktop\REPLACEME** …
Uploading to C:\Users\Dern\Desktop\REPLACEME** …
Error: Exception setting “SessionLogPath”: “Object is disposed”

Is seems to entirely skip, which is the first one.

Also, can anyone enlighten me on why i get this exception error “object is disposed”?

I really hope someone can help me the last bit here! :slight_smile:

Link to code:

Best regards