{"componentChunkName":"component---src-templates-post-template-js","path":"/powershell-get-and-stop-process-en","result":{"data":{"markdownRemark":{"id":"c03a3fcf-d9fb-5bd8-a63e-aa3e95f9a42e","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/powershell-get-and-stop-process\">original page</a>.</p>\n</blockquote>\n<h2 id=\"display-running-processes-with-the-get-process-cmdlet\" style=\"position:relative;\"><a href=\"#display-running-processes-with-the-get-process-cmdlet\" aria-label=\"display running processes with the get process cmdlet permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Display running processes with the <code class=\"language-text\">Get-Process</code> cmdlet</h2>\n<p>In PowerShell, you can use the <code class=\"language-text\">Get-Process</code> command to retrieve a list of running processes.</p>\n<p>With <code class=\"language-text\">Get-Process</code>, you can obtain parameters such as the process name and process ID, as shown below.</p>\n<p>The aliases for <code class=\"language-text\">Get-Process</code> are <code class=\"language-text\">gps</code> and <code class=\"language-text\">ps</code>.<br>\nIt is convenient that it can be used in a Linux-like way.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">PS C:\\Users\\yuki> Get-Process\n\nHandles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName\n-------  ------    -----      -----     ------     --  -- -----------\n    393      23    16348      30068       0.19   7836   2 ApplicationFrameHost\n    569      28    65592      75100   5,603.98  10060   0 audiodg\n    308      35    33364      82540       1.48   1308   2 Code</code></pre></div>\n<p>In addition, with <code class=\"language-text\">Get-Process</code> you can specify which process to display by using the process ID or process name, as shown below.<br>\nThis is normally used to obtain a <strong>known running process, so an error occurs if no matching process is found</strong>.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># Specify a process by process name\nPS C:\\Users\\yuki> Get-Process -Name code\n\nHandles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName\n-------  ------    -----      -----     ------     --  -- -----------\n    821      44    38760      87176      12.59   1364   3 Code\n    245      21    15188      27940       0.19   4216   3 Code\n    531      82   158264     180296      37.78   4984   3 Code\n    657      29   180360     197764       8.73   7232   3 Code\n    400      51    43332      70696      13.98  10328   3 Code\n    438      20     9688      25920       1.11  10820   3 Code\n    311      35    33060      51808       1.48  11996   3 Code\n    227      16     6896      14048       0.09  14204   3 Code\n\n# Specify a process by ID\nPS C:\\Users\\yuki> Get-Process -Id 4216\nHandles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName\n-------  ------    -----      -----     ------     --  -- -----------\n    245      21    15188      27948       0.19   4216   3 Code</code></pre></div>\n<p>By the way, <strong>you can also use wildcards in the process-name search like this</strong>.<br>\nIn this example, specifying <code class=\"language-text\">note*</code> successfully extracts the <code class=\"language-text\">notepad</code> process.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">PS C:\\Users\\yuki> Get-Process -Name note*\n\nHandles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName\n-------  ------    -----      -----     ------     --  -- -----------\n    290      17     4068      18728       0.17   4504   3 notepad</code></pre></div>\n<h2 id=\"stop-a-specific-process-with-the-stop-process-command\" style=\"position:relative;\"><a href=\"#stop-a-specific-process-with-the-stop-process-command\" aria-label=\"stop a specific process with the stop process command permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stop a specific process with the <code class=\"language-text\">Stop-Process</code> command</h2>\n<p>You can also use the <code class=\"language-text\">Stop-Process</code> command to stop a specific process by specifying the process name or process ID.<br>\nThe aliases for <code class=\"language-text\">Stop-Process</code> are <code class=\"language-text\">kill</code> and <code class=\"language-text\">spps</code>.</p>\n<p>The <code class=\"language-text\">kill</code> command is the same as in Bash, so it is very easy to use.</p>\n<p>In the following example, <code class=\"language-text\">Stop-Process</code> is used to stop the <code class=\"language-text\">notepad</code> process.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># Confirm that the notepad process is running\nPS C:\\Users\\yuki> Get-Process -Name note*\n\nHandles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName\n-------  ------    -----      -----     ------     --  -- -----------\n    290      17     4068      18728       0.17   4504   3 notepad\n\n# Stop the notepad process\nPS C:\\Users\\yuki> Stop-Process -Name notepad\n\n# When you check for the notepad process again, an error is returned because the process is no longer found\nPS C:\\Users\\yuki> Get-Process -Name notepad\npython -q\necho  行:1 文字:1\n+ Get-Process -Name notepad\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~\n    + CategoryInfo          : ObjectNotFound: (notepad:String) [Get-Process], ProcessCommandException\n    + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand</code></pre></div>\n<p>You can also perform more complex processing by using command output in this filter portion.</p>\n<p>For example, the <a target=\"_blank\" href=\"https://docs.microsoft.com/ja-jp/powershell/scripting/samples/managing-processes-with-process-cmdlets?view=powershell-7\" rel=\"noopener noreferrer\">official documentation</a> introduces the following <strong>one-liner for stopping all processes in a “Not Responding” state</strong>.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">Get-Process | Where-Object -FilterScript {$_.Responding -eq $false} | Stop-Process</code></pre></div>\n<p>It is pretty convenient to be able to quickly stop non-responsive processes.<br>\nYou no longer have to visually search for them one by one in Task Manager.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>This time, I summarized the <code class=\"language-text\">Get-Process</code> command for checking PowerShell processes and the <code class=\"language-text\">Stop-Process</code> command for stopping any process.<br>\nMany PowerShell commands are assigned the same aliases as familiar Bash commands, and I find them very comfortable to use.</p>\n<h2 id=\"references\" style=\"position:relative;\"><a href=\"#references\" aria-label=\"references permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>References</h2>\n<ul>\n<li><a target=\"_blank\" href=\"https://docs.microsoft.com/ja-jp/powershell/module/Microsoft.PowerShell.Management/Get-Process?view=powershell-7\" rel=\"noopener noreferrer\">Get-Process</a></li>\n<li><a target=\"_blank\" href=\"https://docs.microsoft.com/ja-jp/powershell/scripting/samples/managing-processes-with-process-cmdlets?view=powershell-7\" rel=\"noopener noreferrer\">Managing Processes with Process Cmdlets - PowerShell | Microsoft Docs</a></li>\n</ul>\n<h2 id=\"commands-introduced-this-time\" style=\"position:relative;\"><a href=\"#commands-introduced-this-time\" aria-label=\"commands introduced this time permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Commands introduced this time</h2>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">Name\n    <span class=\"token function\">Get-Process</span>\n\nSyntax\n    <span class=\"token function\">Get-Process</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token operator\">-</span>Name<span class=\"token punctuation\">]</span> &lt;string<span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span>><span class=\"token punctuation\">]</span>  <span class=\"token punctuation\">[</span>&lt;CommonParameters><span class=\"token punctuation\">]</span>\n\n    <span class=\"token function\">Get-Process</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token operator\">-</span>Name<span class=\"token punctuation\">]</span> &lt;string<span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span>><span class=\"token punctuation\">]</span>  <span class=\"token punctuation\">[</span>&lt;CommonParameters><span class=\"token punctuation\">]</span>\n\n    <span class=\"token function\">Get-Process</span>  <span class=\"token punctuation\">[</span>&lt;CommonParameters><span class=\"token punctuation\">]</span>\n\n    <span class=\"token function\">Get-Process</span>  <span class=\"token punctuation\">[</span>&lt;CommonParameters><span class=\"token punctuation\">]</span>\n\n    <span class=\"token function\">Get-Process</span>  <span class=\"token punctuation\">[</span>&lt;CommonParameters><span class=\"token punctuation\">]</span>\n\n    <span class=\"token function\">Get-Process</span>  <span class=\"token punctuation\">[</span>&lt;CommonParameters><span class=\"token punctuation\">]</span>\n\n\nAliases\n    <span class=\"token function\">gps</span>\n    <span class=\"token function\">ps</span></code></pre></div>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">Name\n    <span class=\"token function\">Stop-Process</span>\n\nSyntax\n    <span class=\"token function\">Stop-Process</span> <span class=\"token punctuation\">[</span><span class=\"token operator\">-</span>Id<span class=\"token punctuation\">]</span> &lt;int<span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span>>  <span class=\"token punctuation\">[</span>&lt;CommonParameters><span class=\"token punctuation\">]</span>\n\n    <span class=\"token function\">Stop-Process</span>  <span class=\"token punctuation\">[</span>&lt;CommonParameters><span class=\"token punctuation\">]</span>\n\n    <span class=\"token function\">Stop-Process</span> <span class=\"token punctuation\">[</span><span class=\"token operator\">-</span>InputObject<span class=\"token punctuation\">]</span> &lt;<span class=\"token keyword\">Process</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span>>  <span class=\"token punctuation\">[</span>&lt;CommonParameters><span class=\"token punctuation\">]</span>\n\n\nAliases\n    <span class=\"token function\">spps</span>\n    <span class=\"token function\">kill</span></code></pre></div>","fields":{"slug":"/powershell-get-and-stop-process-en","tagSlugs":["/tag/power-shell-en/","/tag/windows-en/","/tag/english/"]},"frontmatter":{"date":"2020-07-01","description":"This article summarizes how to obtain a process list with PowerShell, which is also useful for troubleshooting.","tags":["PowerShell (en)","Windows (en)","English"],"title":"Managing processes in PowerShell with Get-Process and Stop-Process","socialImage":{"publicURL":"/static/dc4d8b7f8795f3c3d3489d9957d155f2/no-image.png"}}}},"pageContext":{"slug":"/powershell-get-and-stop-process-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}