{"id":1086,"date":"2021-06-03T13:05:51","date_gmt":"2021-06-03T13:05:51","guid":{"rendered":"https:\/\/www.velaninfo.com\/rs\/?post_type=techtips&#038;p=1086"},"modified":"2021-06-03T13:11:37","modified_gmt":"2021-06-03T13:11:37","slug":"windows-process-with-powershell","status":"publish","type":"techtips","link":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/","title":{"rendered":"How to Manage Windows Processes with PowerShell?"},"content":{"rendered":"<p>PowerShell is a powerful tool for managing processes on a local or remote computer. You can retrieve a list of running processes with PowerShell, suspend a hung process, find a process by a windows title, run a new process in hidden or interactive mode, and so forth.<\/p>\n<p>In Windows 10, you can see a list of possible process management cmdlets as follows:<\/p>\n<p>Get-Command \u2013Noun Process<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1087\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-11.png\" alt=\"Get-Command \u2013Noun Process\" width=\"593\" height=\"144\" \/><\/p>\n<ul>\n<li><strong>Get-Process<\/strong>\u2013 get a list of running Windows processes;<\/li>\n<li><strong>Start-Process<\/strong>\u2013 start a process\/program;<\/li>\n<li><strong>Stop-Process<\/strong>\u2013 forcibly stop (kill) the process;<\/li>\n<li><strong>Debug-Process<\/strong>\u2013 debug a process;<\/li>\n<li><strong>Wait-Process<\/strong>\u2013 wait till the process ends<\/li>\n<\/ul>\n<h3><strong>Get-Process: Getting a List of Running Processes<\/strong><\/h3>\n<p>The Get-Process cmdlet displays a list of processes running on a local computer<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1088\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled.png\" alt=\"Getting a List of Running Processes\" width=\"627\" height=\"263\" \/><\/p>\n<ul>\n<li>These attributes of running processes are presented by default:<\/li>\n<li>Handles \u2013 the total amount of input-output file descriptors (handles) that this process has opened;<\/li>\n<li><strong>NPM(K)<\/strong>\u00a0\u2013 is a non-paged memory. This is the size of the process data (in KB) that is never paged on disk;<\/li>\n<li><strong>PM(K) \u2013\u00a0<\/strong>the size of the process memory that may be paged;<\/li>\n<li><strong>WS(K)<\/strong>\u00a0\u2013 the size of physical memory (in KB) used by the process (Working Set);<\/li>\n<li><strong>CPU(s)\u00a0<\/strong>\u2013 a CPU time used by the process (time on all CPUs is counted);<\/li>\n<li><strong>ID<\/strong>\u00a0\u2013 unique process identifier;<\/li>\n<li><strong>SI<\/strong>\u00a0(Session ID) \u2013 is the process session ID (0 means running for all sessions, 1- running for the first logged on user, 2 \u2014 running for the second logged on user, etc.);<\/li>\n<li><strong>ProcessName<\/strong><\/li>\n<\/ul>\n<p><strong>To list all properties of multiple processes:<\/strong><\/p>\n<p>Get-Process cmd,excel,notep* | Format-List *<\/p>\n<p>You can display the specific process properties only, for example, a name (ProcessName), a start time (StartTime), a process window title (MainWindowTitle), an executable file name (Path) and a developer name (Company):<\/p>\n<p>Get-Process winword, notep* | Select-Object ProcessName, StartTime, MainWindowTitle, Path, Company|ft<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1089\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-3.png\" alt=\"Get-Process cmd,excel,notep* \" width=\"703\" height=\"73\" \/><\/p>\n<p>To show a list of currently running user processes in a graphical user interface (background and system processes will not be shown):<\/p>\n<p>Get-Process | Where-Object {$_.mainWindowTitle} | Format-Table Id, Name, mainWindowtitle<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1090\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-4.png\" alt=\"| Format-Table Id, Name, mainWindowtitle\" width=\"601\" height=\"148\" \/><\/p>\n<p>Using the\u00a0<strong>IncludeUserName<\/strong>\u00a0option, you can display a user name (owner) who has started the process:<\/p>\n<p>Get-Process -Name winword\u2013IncludeUserName<\/p>\n<p>You can use Where-Object to choose processes based on certain criteria. For example, let&#8217;s show all programs that use more than 300 MB of RAM, arrange them by memory usage in descending order, and display the memory amount in MB rather than KB:<\/p>\n<p>Get-Process| where-object {$_.WorkingSet -GT 300000*1024}|select processname,@{l=&#8221;Used RAM(MB)&#8221;; e={$_.workingset \/ 1mb}} |sort &#8220;Used RAM(MB)&#8221; \u2013Descending<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1091\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-5.png\" alt=\"Get-Process -Name winword\u2013IncludeUserName\" width=\"692\" height=\"97\" \/><\/p>\n<p>As previously stated, the CPU parameter of the Get-Process cmdlet contains the processor time consumed by the specific process in seconds. Use this function to see the proportion of CPU consumed by programmes (similar to Task Manager):<\/p>\n<p>function Get-CPUUsagePercent<br \/>\n{<br \/>\n$CPUPercent = @{<br \/>\nName = &#8216;CPUPercent&#8217;<br \/>\nExpression = {<br \/>\n$TotalSec = (New-TimeSpan -Start $_.StartTime).TotalSeconds<br \/>\n[Math]::Round( ($_.CPU * 100 \/ $TotalSec), 2)<br \/>\n}<br \/>\n}<br \/>\nGet-Process | Select-Object -Property Name, $CPUPercent, Description | Sort-Object -Property CPUPercent -Descending | Select-Object -First 20<br \/>\n}<br \/>\nGet-CPUUsagePercent<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1092\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-6.png\" alt=\"function Get-CPUUsagePercent\" width=\"455\" height=\"190\" \/><\/p>\n<p>To find hung processes (which are not responding), run the following command:<\/p>\n<p>Get-Process | where-object {$_.Responding -eq $false}<\/p>\n<h3><strong>Start-Process, Stop-Process: How to Start or Stop Processes with PowerShell<\/strong><\/h3>\n<p>To start a new process using PowerShell, this command is used:<\/p>\n<p>Start-Process -FilePath notepad<\/p>\n<p>If there is no executable file in the\u00a0$env:path\u00a0environment variable, specify the full path to the file:<\/p>\n<p>Start-Process -FilePath &#8216;C:\\distr\\app.exe&#8217;<\/p>\n<p>You can run a program and pass arguments to it:<\/p>\n<p>Start-Process -FilePath ping -ArgumentList &#8220;-n 10 10.1.56.21&#8221;<\/p>\n<p>You can change the process window&#8217;s start mode with the WindowStyle parameter (normal, minimized, maximized, hidden). Execute this command, for example, to run a programme in a maximised window and wait for it to finish:<\/p>\n<p>Start-Process -FilePathtracert -ArgumentList &#8220;10.1.56.21&#8221; \u2013wait -windowstyle Maximized<\/p>\n<p>Using Stop-Process cmdlet, you can stop any process. For instance, to close all running notepad processes:<\/p>\n<p>Stop-Process -Name notepad<\/p>\n<p>You are not requested to confirm stopping a process by default. All procedures that meet the requirements will be halted. Add the \u2013Confirm option to be able to confirm halting processes:<\/p>\n<p>Stop-Process -Name notepad.exe \u2013Confirm<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1093\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-7.png\" alt=\"Stop-Process -Name notepad.exe \u2013Confirm\" width=\"503\" height=\"75\" \/><\/p>\n<p>Also, you can kill a process as follows:<\/p>\n<p>(Get-Process -Name cmd).Kill()<\/p>\n<p>From PowerShell, you can force stop all apps that are not responding to Windows Process Manager:<\/p>\n<p>Get-Process | where-object {$_.Responding -eq $false}| Stop-Process<\/p>\n<p>Using PowerShell, you can automatically restart a hung or closed process.<\/p>\n<h3><strong>Using PowerShell to Manage Processes on a Remote Computer<\/strong><\/h3>\n<p>You can use the\u00a0ComputerName\u00a0option of the Get-Process cmdlet in order to manage processes on remote computers (WinRM must be enabled and configured).<\/p>\n<p>Get-Process -ComputerName srv01, srv02, srv03| Format-Table -Property ProcessName, ID, MachineName<\/p>\n<p>We deal with the built-in Get-Process features to manage processes on remote computers. PowerShell Remoting features available in\u00a0Invoke-Command\u00a0and\u00a0Enter-PSSession\u00a0cmdlets are not covered here.<\/p>\n<p>Note that the Stop-Process cmdlet does not have the \u2013ComputerName parameter if you wish to stop a process on a remote computer. You can use the following PowerShell code to stop a process on a remote computer:<\/p>\n<p>$RemoteProcess = Get-Process -Name cmd -ComputerName srv01<br \/>\nStop-Process -InputObject $RemoteProcess<\/p>\n<p>At <strong>Velan<\/strong>, our server support engineers can manage your server.\u00a0If you are interested in our service, please fill the Quick connect form to<a href=\"https:\/\/www.velaninfo.com\/contact\"><strong> get in touch with us<\/strong><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PowerShell is a powerful tool for managing processes on a local or remote computer. You can retrieve a list of running processes with PowerShell, suspend a hung process, find a process by a windows title, run a new process in hidden or interactive mode, and so forth. In Windows 10, you can see a list&#8230;<a class=\"continue-reading text-uppercase\" href=\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/\"> Continue Reading <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/themes\/velaninfo\/images\/reading_arw.png\" alt=\"Continue Reading\" width=\"16\" height=\"12\"\/><\/a><\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"tags":[],"class_list":["post-1086","techtips","type-techtips","status-publish","hentry","Categories_tech_tip-core","Categories_tech_tip-server-windows","Categories_tech_tip-windows"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v19.5 (Yoast SEO v27.1.1) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>What is PowerShell Starting Windows Process | Velan<\/title>\n<meta name=\"description\" content=\"How to Manage Windows Processes with PowerShell? PowerShell is a scripting language that allows users to automate and manage Windows\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Manage Windows Processes with PowerShell?\" \/>\n<meta property=\"og:description\" content=\"How to Manage Windows Processes with PowerShell? PowerShell is a scripting language that allows users to automate and manage Windows\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"Velan\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-03T13:11:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-11.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/\",\"url\":\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/\",\"name\":\"What is PowerShell Starting Windows Process | Velan\",\"isPartOf\":{\"@id\":\"https:\/\/www.velaninfo.com\/rs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-11.png\",\"datePublished\":\"2021-06-03T13:05:51+00:00\",\"dateModified\":\"2021-06-03T13:11:37+00:00\",\"description\":\"How to Manage Windows Processes with PowerShell? PowerShell is a scripting language that allows users to automate and manage Windows\",\"breadcrumb\":{\"@id\":\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#primaryimage\",\"url\":\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-11.png\",\"contentUrl\":\"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-11.png\",\"width\":593,\"height\":144,\"caption\":\"Get-Command \u2013Noun Process\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.velaninfo.com\/rs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tech Tips\",\"item\":\"https:\/\/www.velaninfo.com\/rs\/techtips\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Manage Windows Processes with PowerShell?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.velaninfo.com\/rs\/#website\",\"url\":\"https:\/\/www.velaninfo.com\/rs\/\",\"name\":\"Velan\",\"description\":\"Velaninfo Services India Pvt Ltd\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.velaninfo.com\/rs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"What is PowerShell Starting Windows Process | Velan","description":"How to Manage Windows Processes with PowerShell? PowerShell is a scripting language that allows users to automate and manage Windows","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"How to Manage Windows Processes with PowerShell?","og_description":"How to Manage Windows Processes with PowerShell? PowerShell is a scripting language that allows users to automate and manage Windows","og_url":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/","og_site_name":"Velan","article_modified_time":"2021-06-03T13:11:37+00:00","og_image":[{"url":"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-11.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/","url":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/","name":"What is PowerShell Starting Windows Process | Velan","isPartOf":{"@id":"https:\/\/www.velaninfo.com\/rs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-11.png","datePublished":"2021-06-03T13:05:51+00:00","dateModified":"2021-06-03T13:11:37+00:00","description":"How to Manage Windows Processes with PowerShell? PowerShell is a scripting language that allows users to automate and manage Windows","breadcrumb":{"@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#primaryimage","url":"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-11.png","contentUrl":"https:\/\/www.velaninfo.com\/rs\/wp-content\/uploads\/2021\/06\/Untitled-11.png","width":593,"height":144,"caption":"Get-Command \u2013Noun Process"},{"@type":"BreadcrumbList","@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/windows-process-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.velaninfo.com\/rs\/"},{"@type":"ListItem","position":2,"name":"Tech Tips","item":"https:\/\/www.velaninfo.com\/rs\/techtips\/"},{"@type":"ListItem","position":3,"name":"How to Manage Windows Processes with PowerShell?"}]},{"@type":"WebSite","@id":"https:\/\/www.velaninfo.com\/rs\/#website","url":"https:\/\/www.velaninfo.com\/rs\/","name":"Velan","description":"Velaninfo Services India Pvt Ltd","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.velaninfo.com\/rs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips\/1086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips"}],"about":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/types\/techtips"}],"author":[{"embeddable":true,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/comments?post=1086"}],"version-history":[{"count":2,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips\/1086\/revisions"}],"predecessor-version":[{"id":1095,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips\/1086\/revisions\/1095"}],"wp:attachment":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/media?parent=1086"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/tags?post=1086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}