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.

Tuesday, November 4, 2014

PowerShell Script to list Worker Processors and their Application Pool Names with Memory consumption and CPU utilization.


Using the following Power Shell Script you will be able to enumerate worker processors and associated Application Pool Names with details of Memory consumption and CPU Utilization, that will help during investigation and troubleshooting when System Resources are in critical condition. 


The PS Script will list PID (Processor ID), VM (Virtual Memory), PM (Physical Memory), WS (Working Set), CPU utilization, with ‘Application Pool Name’.

$list = get-process w3wp
$lineitems = @()
   foreach($p in $list)
   {
                $linestr = New-Object PSObject
                $filter = "Handle='" + $p.Id + "'"
                $wmip = get-WmiObject Win32_Process -filter $filter
                $cmdline = $wmip.CommandLine
               
                [regex]$pattern="-ap ""(.+)"""
                $PoolNameStr = $pattern.Match($cmdline).Groups[1].Value
                $PoolName = $PoolNameStr.substring(0, $PoolNameStr.IndexOf(""""))

                $linestr | add-member NoteProperty Id  $p.Id
                $linestr | add-member NoteProperty VM $p.VM
                $linestr | add-member NoteProperty PM  $p.PM
                $linestr | add-member NoteProperty WS  $p.WS
                $linestr | add-member NoteProperty CPU  $p.CPU
                $linestr |  add-member NoteProperty "AppPoolName" $PoolName
                $lineitems += $linestr
   }
$lineitems | Format-Table * -AutoSize

Format-Table


Out-GridView

You can also use Grid View parameter which displays data in Grid View.




No comments:

Post a Comment