question

BenVanDoorsselaere-6768 avatar image
0 Votes"
BenVanDoorsselaere-6768 asked BenVanDoorsselaere-6768 commented

Incompatibility between Get-WebApplication and Write-Progress?

I can’t seem to find a reason, so I hope you can shine a light.
Following code doesn’t execute the second write-progress.
The output for get-webapplication is shown in my receive-job, so the command executes correctly.
I can execute other commands after the get-webapplication and they work fine as well.
But not write-progress

If I change the get-webapplication to get-process, then everything works ok.
Why does get-webapplication block every subsequent write-progress?

As info:
PSVersionTable for my webserver

Name Value


PSVersion 5.1.14393.3866
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3866
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1


 cls
 $Computer = "SomeWebserver"
    
 function Dummy{
     Import-Module webadministration
     Write-Progress -PercentComplete 10 -Activity "Dummy" -CurrentOperation "testing"
     Get-WebApplication
     #Get-Process
     Write-Progress -PercentComplete 20 -Activity "Dummy" -CurrentOperation "testing2"
    
 }
 $job = invoke-command -asjob -ComputerName $Computer -ScriptBlock ${Function:Dummy}
 $job | Wait-Job | Receive-Job
 $job.ChildJobs[0].progress




windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered BenVanDoorsselaere-6768 commented

Hi,

I tested the function on PowerShell 5.1 and it worked well for me.

86688-record.gif


Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




record.gif (301.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you very much for testing it out.
I also added a sleep, and now i notice that my progress bar is also displaying the hop to 20%
I never noticed this without the sleep.

However, $job.ChildJobs[0].progress still doesn't contain the second write-progress when using get-webapplication but does show it when using get-process.
I don't know how to investigate this further, would you have a suggestion?

0 Votes 0 ·