Upload 2 Files with different names (no wildcards)
Hi,
my problem is this: I have to upload 2 files with different names. One file is created by MS SQL Reporting Services, let's call it Export.csv. The other is created by a Powershell script and contains the MD5 Hash of the first file. Let's call it Hash.txt.
Now I have to upload them and give them a different name (adding a timestamp to the file name). What I have done so far is:
This works so far.
My question is: Is there a way to upload these two files in one step, something like
Thanks for your help!
Michael
my problem is this: I have to upload 2 files with different names. One file is created by MS SQL Reporting Services, let's call it Export.csv. The other is created by a Powershell script and contains the MD5 Hash of the first file. Let's call it Hash.txt.
Now I have to upload them and give them a different name (adding a timestamp to the file name). What I have done so far is:
[...] $transferOptions = New-Object WinSCP.TransferOptions $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary $transferResult = $session.PutFiles("C:\PathTo\Export.csv", "Export$(Get-Date -format yyMMddhhmm).csv", $False, $transferOptions) $transferResult.Check() $transferResult = $session.PutFiles("C:\PathTo\Hash.txt", "Hash$(Get-Date -format yyMMddhhmm).txt", $False, $transferOptions) $transferResult.Check() [...]
This works so far.
My question is: Is there a way to upload these two files in one step, something like
[...] $files2upload = @("C:\PathTo\Export.csv", "C:\PathTo\Hash.txt") $renamedFiles = @() foreach($file2upload in $files2upload) { $fileInfo = [io.FileInfo] $file2upload $renamedFiles += ("{0}{1}{2}" -f $fileInfo.BaseName, $(Get-Date -format yyMMddhhmm), $fileInfo.Extension) } $transferResult = $session.PutFiles($files2Upload, $renamedFiles, $False, $transferOptions) [...]
Thanks for your help!
Michael