Prepending date to file during upload in PS script

Advertisement

catmanchampion
Joined:
Posts:
1

Prepending date to file during upload in PS script

Hello, I am fairly new to using winscp and using powershell to script with it. I am working on a script to upload files and was trying to prepend the date to the filename during upload. I was looking at the Operation Mask documentation, but still haven't quite gotten it. Given the code below, I was hoping to transfer two text files "a.txt" and "b.txt" in C:\source to the remote directory /source/withDate with files names "20190523a.txt" "20190523b.txt" respectively. Unfortunately that isn't working and I am getting a directory named with the date instead. Could someone point me in the right direction with the proper operation mask to achieve the date prepending?
$DateStr = Get-Date -format "yyyyMMdd"
 
$session.PutFiles("C:\source", #Source Path
                   "/source/withDate/$DateStr*" #Destination Path,
                ).Check() #Check for any errors in the transfer

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum