Skip to content

Instantly share code, notes, and snippets.

@TakashiSasaki
Last active January 4, 2024 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TakashiSasaki/86513381c7ec45285afe12bdf4b64a72 to your computer and use it in GitHub Desktop.
Save TakashiSasaki/86513381c7ec45285afe12bdf4b64a72 to your computer and use it in GitHub Desktop.
This PowerShell script prompts the user to enter a string that should match a part of a process's full path. It then filters all running processes to find ones where the executable path contains the provided substring. The script outputs a formatted table listing the process names, IDs, and their full executable paths that match the criteria. It…

This PowerShell script prompts the user to enter a string that should match a part of a process's full path. It then filters all running processes to find ones where the executable path contains the provided substring. The script outputs a formatted table listing the process names, IDs, and their full executable paths that match the criteria. It's a useful tool for administrators and users who need to quickly identify and inspect running processes based on their file locations. The script pauses at the end, prompting the user to press Enter to exit, allowing time to review the output.

image

$FilterString = Read-Host "Please enter a part of the process's full path"
$FilteredProcesses = Get-Process |
Where-Object { $_.MainModule -and ($_.MainModule.FileName -match $FilterString) } |
Select-Object Name, Id, @{Name="Path";Expression={$_.MainModule.FileName}}
$FilteredProcesses | Format-Table -AutoSize
Read-Host -Prompt "Press Enter to exit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment