Right now I have a powershell script that is callign an FTP request bundled in a CMD file.
It works, but I want to integrate the FTP request in the powershell script because it'll give me 1 less file to keep track of.
So far I have tried doing this, but it produces an error (see below).
# run the command script to extract the file
#defines command to be run
$command = '
@echo off
setlocal
set uname=name
set passw=pass
set hostname=hstname
set filespec=spec
echo %uname%> test.ftp
echo %passw%>> test.ftp
echo cd DIRNAME>> test.ftp
echo binary>> test.ftp
echo get %filespec%>> test.ftp
echo bye>> test.ftp
ftp -s:test.ftp %hostname%
if errorlevel 1 pause
endlocal
'
# runs command
iex $command
Error:
Invoke-Expression : The splatting operator '@' cannot be used to reference variables in an expression. '@echo' can be used only as an argument to a command. To reference variables in an expression use '$echo'. At Dir\File.ps1:32 char:4 + iex <<<< $command + CategoryInfo : ParserError: (echo:String) [Invoke-Expression], ParseException + FullyQualifiedErrorId : SplattingNotPermitted,Microsoft.PowerShell.Commands.InvokeExpressionCommand
I also tried changing the script to $echo but it produces the following error:
Invoke-Expression : Unexpected token 'off' in expression or statement. At Dir\File.ps1:32 char:4 + iex <<<< $command + CategoryInfo : ParserError: (off:String) [Invoke-Expression], ParseException + FullyQualifiedErrorId : UnexpectedToken,Microsoft.PowerShell.Commands.InvokeExpressionCommand