Share via


PowerShell: Get Process for SharePoint 2013 NodeRunners

Save the code below to a file named something like getNodeRunnerProcess.ps1 and then run it using any of the following:

  • To get all the noderunner processes on the current server:

    • getNodeRunnerProcess.ps1
  • To get all the noderunner processes on a specified server:

    • getNodeRunnerProcess.ps1 someServerName
  • To get the noderunner for a specific component name (assuming you only have one SSA in the farm and the name specified matches at least one of the active components):

    • getNodeRunnerProcess.ps1 IndexComponent1

 Code Sample:

if ($args[0] -ne $null) {    $SSA = Get-SPEnterpriseSearchServiceApplication    $firstParam = $args[0]       $targetComponent = $SSA.ActiveTopology.GetComponents() | Where {$_.Name -ieq $firstParam}        #if the command line arg specifies an existing search component       if ($targetComponent -ne $null) {               #Set the server name where this component is running              $serverName = $targetComponent.ServerName                           #And set the $targetComponent as this parameter              $targetComponentName = $firstParam        } else {              #assume the command line arg references another server              $serverName = $firstParam       }} else {       #default to all components on this local server       $serverName = $ENV:COMPUTERNAME} Write-Host ("Server: " + $serverName)if ($targetComponentName -ne $null) {    Write-Host ("Comp: " + $targetComponentName)}Write-Host ("=======================================") $nodeRunnerProcesses = (Get-Process noderunner -ComputerName $serverName -ErrorAction SilentlyContinue)foreach ($noderunner in $nodeRunnerProcesses) {       $noderunner | Add-Member -Force -MemberType NoteProperty -Name _ProcessCommandLine -Value $(              (Get-WmiObject Win32_Process -ComputerName $serverName | where {$_.processId -eq $noderunner.id}).CommandLine       )       if ($targetComponentName -ne $null) {              if ($noderunner._ProcessCommandLine -ilike $("*" + $targetComponentName + "*")) {                     $noderunner              }       } else {              $delimPos = $($noderunner._ProcessCommandLine).IndexOf("Nodes")              $stub = $($noderunner._ProcessCommandLine).SubString($delimPos)              $delimPos = $stub.IndexOf("`"")              $derivedCompName = $stub.SubString(0,$delimPos)              $derivedCompName              Write-Host ("------------------------")              $noderunner           Write-Host       }}

--------------Example Output--------------****

PS D:\toolbox> .\getNodeRunnerProcess.ps1

Server: SPServer5

=======================================

IndexComponent1


Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName

-------  ------    -----      ----- -----   ------     -- -----------

   1612     157   511112     326368  1781 6,776.89   2488 noderunner

QueryProcessingComponent1


   1885     208   365876     372716 -1142   651.38   2564 noderunner

 

PS D:\toolbox> .\getNodeRunnerProcess.ps1 spserver3

Server: SPServer3

=======================================

AdminComponent1


Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName

-------  ------    -----      ----- -----   ------     -- -----------

   2070     192   543016     552396  1542            2680 noderunner

AnalyticsProcessingComponent1


   1930     188   259624     272752 -1285            2912 noderunner

ContentProcessingComponent1


   1959     208   847500     904156    47            2920 noderunner

 

PS D:\toolbox> .\getNodeRunnerProcess.ps1 AdminComponent1

Server: SPServer3

Comp: AdminComponent1

=======================================

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName

-------  ------    -----      ----- -----   ------     -- -----------

   2136     192   543084     552432  1544            2680 noderunner