powershelliis-10windows-server-2019web-administration

Why does dir iis:\appname\workerprocesses have an incorrect result?


On my Windows Server 2019 VM, I used this to check on the worker process:

C:\users\rpresser> ipmo webadministration
c:\users\rpresser> dir iis:\myappPoolName\workerprocesses
Process  State      Handles  Start Time
Id
-------- -----      -------  ----------
4728     Running

This is incorrect. Process 4728 was previously a worker process for this app pool but has been terminated. I tried restart-webapppool and even iisreset and both of those started up new worker processes for my app pool but the dir output continues to refer to process 4728.


Solution

  • Even removing the iis psdrive and recreating it doesn't refresh the workerprocess PID. I'd recommend sticking to this to reliably get the PID in an existing session

    $pid = powershell.exe -noprofile -command "Import-Module WebAdministration;dir IIS:\AppPools\MyAppPool\WorkerProcesses\"
    

    This will start a temporary powershell session and get you the accurate info.