Add datestamp to files or create folder with date stamp
                Hi the a standard script retrieved from this forum wich work as design. I will like to make some modification but have failed in making it work.
Steps
I connect to and sftp site and upload all files from directory "C:\temp\send\", then I move the files to backup location "C:\temp\Backup\"
This scripts is scheduled to run every day during a specific time or it can also be run manually. What I will like to do is for each day that the scripts run to to create subfolder under "C:\temp\Backup\" with the current day "C:\temp\Backup\20141004" and the files that have uploaded to the sftp site.
option 2
when moving the files from "C:\temp\send\" to "C:\temp\Backup\"
is to add time stamp to all the files, for example, the filenames gytcxs.txt= 20141004_gytcxs.txt
tsystt.trn=20141004_tsystt.trn
yhftdt.bat=20141004_yhftdt.bat
This is the powershell script
    
Any help will be greatly appreciated
            
        Steps
I connect to and sftp site and upload all files from directory "C:\temp\send\", then I move the files to backup location "C:\temp\Backup\"
This scripts is scheduled to run every day during a specific time or it can also be run manually. What I will like to do is for each day that the scripts run to to create subfolder under "C:\temp\Backup\" with the current day "C:\temp\Backup\20141004" and the files that have uploaded to the sftp site.
option 2
when moving the files from "C:\temp\send\" to "C:\temp\Backup\"
is to add time stamp to all the files, for example, the filenames gytcxs.txt= 20141004_gytcxs.txt
tsystt.trn=20141004_tsystt.trn
yhftdt.bat=20141004_yhftdt.bat
This is the powershell script
try
{
    # Load WinSCP .NET assembly
    [Reflection.Assembly]::LoadFrom("\\C:\Program Files\WinSCP\WinSCPnet.dll") | Out-Null
 
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions
    $sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
    $sessionOptions.HostName = "192.20.xxx.xx"
    $sessionOptions.PortNumber = 22   
    $sessionOptions.UserName = "sample"
    $sessionOptions.Password = "Password$1@"
    $sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:x:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
 
    $session = New-Object WinSCP.Session
 
    try
    {
        # Connect
        $session.Open($sessionOptions)
 
        $localPath = "C:\temp\send\*.*"
        $remotePath = "/home/DEV/"
        $backupPath = "C:\temp\Backup\"
 
        # Upload files, collect results
        $transferResult = $session.PutFiles($localPath, $remotePath)
 
        # Iterate over every transfer
        foreach ($transfer in $transferResult.Transfers)
        {
            # Success or error?
            if ($transfer.Error -eq $Null)
            {
                Write-Host ("Upload of {0} succeeded, moving to backup location" -f
                 $transfer.FileName)
                # Upload succeeded, move source file to backup
                Move-Item $transfer.FileName $backupPath
            }
            else
            {
                Write-Host ("Upload of {0} failed: {1}" -f
                    $transfer.FileName, $transfer.Error.Message)
            }
        }
    }
    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
 
    exit 0
}
catch [Exception]
{
    Write-Host $_.Exception.Message
    exit 1
}Any help will be greatly appreciated