I have a PowerShell script that starts a process to open our FTP client and download some files. It works great on it's own but I now need to pass a variable to it but the result of that variable needs to be in quotes and I'm struggling with how best to do that.
Here is what I use now that works very well:
Start-process "C:\Program Files (x86)\Ipswitch\WS_FTP 12\wsftppro.exe" -ArgumentList "-s TESTCONN:/ -d local:C:\Test\"
What I need to do is change the item in quotes after -ArgumentList to include a variable. I can't figure out how to set this up so that variable is in quotes when it's in the Start-process line:
$PDate = Get-Date -Format yyyyMMdd
$arglist = "-s TESTCONN:/" + $PDate + "* -d local:C:\Test\"
Start-process "C:\Program Files (x86)\Ipswitch\WS_FTP 12\wsftppro.exe" -ArgumentList $arglist
I need the final command to look like this (assuming date of 2022-05-20):
Start-process "C:\Program Files (x86)\Ipswitch\WS_FTP 12\wsftppro.exe" -ArgumentList "-s TESTCONN:/20220520* -d local:C:\Test\"
I've tried double quotes, single quotes and multiple combinations of the two but I cannot get it to output correctly.
What am I missing?
Thanks in advance.