Downloading / reading specific line from PHP file remotely (WinSCP)

Hi everyone.

I am trying to get more familiar with WINSCP / powershell file handling, and i am quite the rookie so my questions here might be beginner ones.

I am attempting to download files from a shared hosting server, but i only want to target a specific file.
In this case i was to download this file from all domains on the server:
domainname/wp-config.php

This have succeeded somewhat, but i am struggling with modifying my script to use a list of filepaths.
I want to make the list like this:

domainname1.dk/wp-config.php
domainname2.dk/wp-config-php - and so on.
( in some cases i might want to get other php files too )

My script tells me:
Error: Exception calling “Check” with “0” argument(s): “Can’t get attributes of file ‘C:\Users\Dern\Desktop\Searchtarget\searchtargetlist.txt’.
Could not retrieve file information
‘/C:\Users\Dern\Desktop\Searchtarget\searchtargetlist.txt’ cannot be listed”

And i really cant seem to figure out why…

Link to my script:
https://gist.github.com/Jonatantwn/39c3ff9178c6711856da6cbdd26ca642

I bet some of you more experienced scripters can point out my mistake…
Please help! :slight_smile:

Best regards
Jonatan

Also i am actually (which is the final point of the script) trying to get my script to read a specifik line in the php file, and print it out for me.

The end goal, is to be able to scan the entire server of all domains, in order to print out this section from ALL wp-config.php files:

define( 'DB_NAME', 'database_nametest2' );

The “database_nametest2” is varaible, so im guessing i would somehow have to target the line DB_NAME and print the full length of the line if it matches.

I have spent quite a bunch of hours trying to figure out how to do this with a remote session, with no luck so far.

If anyone cant point me in the right direction here, that would also be greatly appreaciated!