About Me

SharePoint Architect with over 17 years of IT Experience in various roles as SharePoint Architect, Administrator, Technical Architect, IT Analyst, Application Developer, CRM Consultant, BI Developer, Microsoft Solution Architect in Client/Server, Web and Enterprise CRM Applications in E-Commerce, Financial, Healthcare, Insurance, Telecom, Outsourcing and Technology Services.
MCITP (Pro): Microsoft Certified IT Professional: SharePoint 2010 Administrator.
MCTS: Microsoft Certified Technology Specialist, SharePoint 2010 Configuration.

Monday, October 24, 2011

Get Worker Process with Application Pool Names and Memories

$list = gwmi win32_process -computername "Useaihp460" -filter "name='w3wp.exe'" | Select-Object @{Name="WS";Expression={ ($_.WS/ 1MB).ToString("0,000.0") } }, @{Name="VM";Expression={ ($_.VM / 1MB).ToString("0,000.0") } },@{Name="ProcessId";Expression={ $_.ProcessId.ToString("00000") } }, @{Name="Name";Expression={ $_.Name.ToString() } },@{Name="CommandLine";Expression={ $_.CommandLine.ToString() } }
Write-Host “WS      VM      ProcessId      Application Pool Name”
$list | foreach  {
$from = "c:\windows\system32\inetsrv\w3wp.exe -ap ".Length + 1
$locdll = $_.commandLine.IndexOf("webengine4.dll")
$poolnam = $locdll-16-$from
$len=$_.commandLine.Length
$memory = "4096"
$name1 = $_.commandLine.Substring($from , $poolnam)  
Write-Host $_.WS $_.VM $_.processId $name1
#"WS:{0:N0} VM:{1:N0} ProcessId:{2,6} Name:{3,6} Pool:{4}" -f $_.WS.ToString("00,000,000,000"), $_.VM.ToString("00,000,000,000"), $_.processId, $_.name, $name1
#@{Name="WS";Expression={ ($_.WS / 1MB).ToString("0,000.0") } },
#@{Name="VM";Expression={ ($_.VM / 1MB).ToString("0,000.0") } }
}

No comments:

Post a Comment