Progress Bar shows momentarily using .NET in Powershell 4.0

Advertisement

mwetmore
Joined:
Posts:
4
Location:
Philadelphia, Pennsylvania US

Progress Bar shows momentarily using .NET in Powershell 4.0

Progress Bar shows momentarily using .NET in Powershell 4.0

Running in Powershell ISE or in CMD.EXE a progress bar flashes up for a moment. How to prevent this? The script will be run by a scheduler. Not using sync, just $session.PutFiles() and $session.GetFiles() for transfers, all piped to Out-Null.

BTW at https://winscp.net/eng/docs/library_example_listing_files_matching_wildcard this:

foreach ($fileInfo in $directory.Files)

should be:

foreach ($fileInfo in $Files)

Reply with quote

Advertisement

mwetmore
Joined:
Posts:
4
Location:
Philadelphia, Pennsylvania US

Progress bar

When running the ps1 in 4.0 ISE by clicking :arrow: to execute the console shows the full path to the script, then just before the script exits a GUI blue progress bar flashes up on the top of the console. It is a very quick flash, I have to be staring at the right place to see that the short disturbance.

Similarly when I run the script by invoking powershell in a cmd window, there is a quick flash of 'ooo...' that moves across the top of the window.

These are all the assembly methods used, in the order that they occur. The script runs in < 30 seconds

 # SFTP does not have an append verb so it has to be get->append->put
        $rem = "{0}{1}" -f $carrdir, $rcdf
        if ($send -eq "R" -and $session.FileExists($rem)) {
            if ($session.GetFiles($rem, $rcdtemp).IsSuccess) {
                $session.RemoveFiles($rem) | Out-Null
                Get-Content ($rcdtemp) | 
                    Add-Content ("{0}\{1}" -f $temploc, $rcdf)
            } else {
                CleanUp-Exit(2)
            }
        }
        # This creates a directory in $carrdir named like $temploc
        $session.PutFiles($temploc, $carrdir).Check() | Out-Null

        # Get list of files uploaded
        $files = $session.ListDirectory($carrloc).Files | Where { -not $_.IsDirectory }
            # Move the files up into $carrdir
            ForEach ($fileinfo in $files) {
                $session.MoveFile($carrloc + "/" + $fileinfo.Name, $carrdir)
            }
   if ($session.Opened) {
        $session.RemoveFiles($carrloc) | Out-Null
        $session.Dispose()
    }

Reply with quote

martin
Site Admin
martin avatar

Re: Progress bar

WinSCP .NET assembly does not present any progress bar (it has no GUI at all). So it has to be your run-time environment that shows the progress bar.

Reply with quote

Advertisement

You can post new topics in this forum