Kill a Suspended Process on Windows

The powershell cmdlet get-process* does not give you the option to query for processes that are in a specific state. I needed to kill suspended chrome instance left behind by puppetteer ( the web automation library)

# Get the pids for all open chrome isntances
$chromeProcesses = (Get-Process chrome).Id

# Loop through each
$chromeProcesses | ForEach-Object {
    # assign the id for later use
    $processId = $_
    # check its status by calling into the .Net Diagnostics namespace.
    foreach($thread in $threads) {
        if($thread.WaitReason -eq 'Suspended') {
            # command to kill the process if it's status is suspended
            Get-Process chrome | Where-Object {$ -eq $processId} | kill -Force