Differences
This shows you the differences between the selected revisions of the page.
| script_custom_listing_format_csv 2015-08-25 | script_custom_listing_format_csv 2022-06-16 (current) | ||
| Line 10: | Line 10: | ||
| <code powershell> | <code powershell> | ||
| param ( | param ( | ||
| - | $session = "sftp://user:mypassword;fingerprint=ssh-rsa-xx-xx-xx@example.com/", | + | $sessionUrl = "sftp://user:mypassword;fingerprint=ssh-rsa-xxxxxxxxxxx...@example.com/", |
| $remotePath = "/path", | $remotePath = "/path", | ||
| $outFile = "listing.csv" | $outFile = "listing.csv" | ||
| Line 22: | Line 22: | ||
| # Setup session options | # Setup session options | ||
| $sessionOptions = New-Object WinSCP.SessionOptions | $sessionOptions = New-Object WinSCP.SessionOptions | ||
| - | $sessionOptions.ParseUrl($session) | + | $sessionOptions.ParseUrl($sessionUrl) |
| try | try | ||
| Line 41: | Line 41: | ||
| } | } | ||
| - | # Generate a custom listing for ach file in the output file | + | # Generate a custom listing for each file in the output file |
| # Using UTF-16 (Unicode) encoding that Microsoft Excel likes. | # Using UTF-16 (Unicode) encoding that Microsoft Excel likes. | ||
| foreach ($fileInfo in $directory.Files) | foreach ($fileInfo in $directory.Files) | ||
| { | { | ||
| - | ("`"{0}`"`t{1}`t`"{2}`"" -f $fileInfo.Name, $fileInfo.Length, $fileInfo.LastWriteTime) | Out-File -Append $outFile -Encoding Unicode | + | ("`"{0}`"`t{1}`t`"{2}`"" -f |
| + | ···············$fileInfo.Name, $fileInfo.Length, $fileInfo.LastWriteTime) | | ||
| + | ···············Out-File -Append $outFile -Encoding Unicode | ||
| } | } | ||
| Line 58: | Line 60: | ||
| exit 0 | exit 0 | ||
| } | } | ||
| - | catch [Exception] | + | catch |
| { | { | ||
| - | Write-Host $_.Exception.Message | + | Write-Host "Error: $($_.Exception.Message)" |
| exit 1 | exit 1 | ||
| } | } | ||
| Line 77: | Line 79: | ||
| "ls /path" ^ | "ls /path" ^ | ||
| "exit" | "exit" | ||
| - | if %ERRORLEVEL% == 0 msxsl.exe %XMLLOG% listing.xsl > listing_script.csv | + | if %ERRORLEVEL% == 0 msxsl.exe %XMLLOG% listing.xsl > listing.csv |
| </code> | </code> | ||