The Get-Process command in PowerShell is a well-known cmdlet to return basic process information. However, what it does not return is the parent process of a particular process. With the following script, one can find out the parent process of a process with ease. Provide the process name as a parameter and run the following script.
Script
<#
.SYNOPSIS
This script can be used to display parent process name of a process.
.DESCRIPTION
This script can be used to display parent process name of a process.
.EXAMPLE
C:\PS> C:\Script\Parent_Process.ps1 taskhost.
Displays the parent process name of taskhost.
#>
Param([String] $program)
$process = Get-Process -Name $program
#get the process id of the given process
$id = $process.Id
#Obtain The parent process id.
$instance = Get-WmiObject Win32_Process -Filter “ProcessId = ‘$id'”
$instance.ParentProcessId
#Fetch the process with the parentprocess id.
$parentProcess = Get-Process -Id $instance.ParentProcessId
$parentProcess