Powershell write progress in remote session

Welcome Forums General PowerShell Q&A Powershell write progress in remote session

This topic contains 1 reply, has 2 voices, and was last updated by

9 months, 3 weeks ago.

  • Author
  • #101968

    Points: 0
    Rank: Member

    Hello, I have noticed some strange behavior with Powershell when run in a remote session, it seems as if there is a memory leak with write-progress when run in a remote session. Is there something I need to do to manually clear this up? I am running Powershell version 5 on both the calling pc and the target.

    Take the following code for example:

    $MaxVal = 10000000
    for ($x=1;$x -le $MaxVal;$x++)
        Write-Progress -Activity "Writing a progress event" -PercentComplete ($x / $MaxVal * 100) -Status "$($x / $MaxVal * 100)% complete"

    If I run this locally, powershell.exe runs normally and does not take up much memory.

    However, if I run it on the same computer from a remote session (as in, I do an enter-psesssion -computername computer).

    The memory on powershell.exe keeps going up until it eventually crashes the process.

    Is there something I am doing wrong or is this a bug within powershell? I noticed it because I have a long running script that I use write-progress in and it was running fine whenever it runs locally, but calling it in a powershell session kept hanging the script and it would never complete. If I just remove all the calls to write-progress from the script, it runs fine in a remote session.

  • #102071

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    You could certainly open an issue on Write-Progress in the PowerShell GitHub repo.

The topic ‘Powershell write progress in remote session’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort