AfterConnect Parameter (Get-SFTP Cmdlet)
A set of FTP commands to be executed immediately after connecting to the Server .
Get-SFTP -AfterConnect string
AfterConnect is a script that is executed immediately following a successful connection.
The script may contain any number of standard FTP commands.
Each line in the script is treated as a single command. By default, if the cmdlet encounters any errors while executing a command, it will log the error message and will continue to process the script. This behavior can be turned off by inserting "ONERROR FAIL" at any point in the script, which will cause the script to terminate on error but will not interrupt the normal operation of the cmdlet. The default behavior can be restored at any point in the script by inserting the line "ONERROR RESUME".
Valid additional scripting commands are listed below:
|cd Path||Change the remote directory to the specified path.|
|del Filename||Delete the specified file from the remote server.|
|mkdir Directory||Create the specified remote directory on the server.|
|rn Filename NewFilename||Rename the remote file specified by Filename to the NewFilename.|
|move Filename NewFilename||Move the remote file located at Filename to the NewFilename.|
|rm Filename||Remove the specified file from the remote server.|
|rmdir Directory||Remove the remote directory from the server.|
The cmdlet also support the following Macros. These values are not case sensitive and would be supplied to a property in the form %MacroName%.
|Temp||This is resolved to the full path to the system's temporary directory.|
|SourceFileName||The original file name. This includes the extension and excludes the file path, for example, Sample.xml. This macro is only applicable to AfterDownload, AfterUpload, and AfterDelete.|
|DateTime:CustomFormat||This special value allows you to specify your own custom time format. For instance DateTime:yyyy would be resolved to the 4 digit year.|
|Date||The date format yyyy-MM-dd.|
|DateTime||The date format yyyy-MM-ddThhmmss.|
|Time||The date format hhmmss.|
|DateTime_BTS2000||The date format yyyyMMddhhmmssf.|
|DateTime.TZ||The date format yyyy-MM-ddThhmmsszzz.|
|Time.TZ||The date format hhmmsszzz.|