0
私はいくつかのファイルを取得するためにFTP接続を設定するのにpowershell FTP Client Moduleを使用しています。Powershell FTP接続
私は、このようにコマンドの出力をキャプチャすることができることを知っている:私はこのような何かをやっている..私は変数に-Verbose
属性の出力をリダイレクトしたい
$output = (command) | Out-String
が、 FTP接続を作成することはできません、私のscripsは単に停止します。
$output1 = (Set-FTPConnection -Server $ftp_server -Credentials $mycreds -Session $session)
$output2 = (
Get-FTPChildItem -Path $ftp_path -Session $session -Verbose | % {
$ftpFile = "ftpPathIn/$($_.Name)"
Get-FTPItem -Path $ftpFile -LocalPath $PathToFile -Overwrite -Session $session -Verbose
}) | Out-String
PS:出力を変数にリダイレクトせずに、スクリプトは非常にうまく動作します。だから私は、エラーを疑うと、出力を$output
にリダイレクトしようとしています。 変数$ outputの出力をどのようにリダイレクトできますか?
詳細:https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/ –
ありがとうございます!できます!!さようなら – Hari