You can send an arbitrary FTP command with WinSCP .NET assembly used from PowerShell using the Session.ExecuteCommand
method:
try
{
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Ftp
$sessionOptions.HostName = "example.com"
$sessionOptions.UserName = "user"
$sessionOptions.Password = "password"
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
# Execute command
$session.ExecuteCommand("SITE LRECL=132 RECFM=FB").Check()
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch [Exception]
{
Write-Host $_.Exception.Message
exit 1
}
There's also the PowerShell module build on top of WinSCP .NET assembly that you can use like:
$session = New-WinSCPSessionOptions -Protocol Ftp -Hostname example.com -Username user -Password mypassword | Open-WinSCPSession
Invoke-WinSCPCommand -WinSCPSession $session -Command "SITE LRECL=132 RECFM=FB"
(I'm the author of WinSCP)