So, I'm in PowerShell and I can run a command like...
& .\curl.exe -vk -u <username:password> -F <some data> -F <some more data> --url <url here>
That all works fine, but sometimes there are more data entries to add, so more "-F"s to add. Like...
& .\curl.exe -vk -u <username:password> -F <some data> -F <some more data> -F <more data> -F <and another one> --url <url here>
I've tried creating foreach loops and building a long ScriptBlock but it doesn't seem to like that if I use the created string and Invoke-Command. Like this...
$Data = @()
$Data += "some data"
$Data += "more data"
$Data += "even more data"
$Script = @()
$Script += "& .\curl.exe -vk -u <username:password>"
foreach ($D in $Data) {
$Script += "-F $D"
}
$Script += "--url <url here>"
$FinalScript = $Script -join ' '
Invoke-Command -ScriptBlock {$FinalScript}
Any help welcome. Sorry if this is not in the correct format... Newb! Oh and this is on PowerShell 5.1... because Windows!