I am confused how it works -Passthru.
In my opinion, the parameter is -Passthruused to transfer the result of the cmdlet to the pipeline, even the cmdlet itself does not produce any results.
I tried to write this code first: (I'm trying to recycle the IIS application pool without using the cmdlet Restart-WebAppPool)
Stop-WebAppPool -Name Foo
Start-WebAppPool -Name Foo
As I expected, it takes time to stop the IIS ApplicationPool, and since PowerShell did not wait for the cmdlets to complete, it Stop-WebAppPoolstops the application pool and returns. Since the application pool is not ready to start, Start-WebAppPoolan error is called and thrown.
So, I changed my code to the following:
Stop-WebAppPool -Name Foo
Start-Sleep -Seconds SomeValueNeedToGetMeasuredAndChanged
Start-WebAppPool -Name Foo
It works, but not very elegant and flexible.
-Passthru , :
Stop-WebAppPool -Name Foo -Passthru
Start-WebAppPool -Name Foo -Passthru
, .
, :
Stop/Start-WebAppPool , /. -Passthru , - , PowerShell , , /, .
-Passthru, Stop-WebAppPool, ?