{"id":4096,"date":"2013-02-27T11:59:00","date_gmt":"2013-02-27T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/02\/27\/powertip-use-powershell-to-easily-find-how-long-a-process-runs\/"},"modified":"2013-02-27T11:59:00","modified_gmt":"2013-02-27T11:59:00","slug":"powertip-use-powershell-to-easily-find-how-long-a-process-runs","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-use-powershell-to-easily-find-how-long-a-process-runs\/","title":{"rendered":"PowerTip: Use PowerShell to Easily Find How Long a Process Runs"},"content":{"rendered":"<p><strong style=\"font-size: 12px\">Summary:<\/strong><span style=\"font-size: 12px\"> Use Windows PowerShell to show easily how long a process runs.<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;You need to find how long a particular process has been running. How can you easily do this with Windows PowerShell?<\/p>\n<p style=\"padding-left: 30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Use the <strong>New-TimeSpan<\/strong> cmdlet and specify the <strong>&ndash;Start<\/strong> parameter as the results from <strong>Get-Process<\/strong> on a process and the <strong>StartTime<\/strong> property. This is shown here using Notepad as an example.<\/p>\n<p style=\"padding-left: 90px\">PS C:\\&gt; New-TimeSpan -Start (get-process notepad).StartTime<\/p>\n<p style=\"padding-left: 90px\">&nbsp;<\/p>\n<p style=\"padding-left: 90px\">Days&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 0<\/p>\n<p style=\"padding-left: 90px\">Hours&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: 6<\/p>\n<p style=\"padding-left: 90px\">Minutes&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: 53<\/p>\n<p style=\"padding-left: 90px\">Seconds&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: 54<\/p>\n<p style=\"padding-left: 90px\">Milliseconds&nbsp;&nbsp; : 55<\/p>\n<p style=\"padding-left: 90px\">Ticks&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: 248340555164<\/p>\n<p style=\"padding-left: 90px\">TotalDays&nbsp;&nbsp;&nbsp; &nbsp;: 0.287431198106481<\/p>\n<p style=\"padding-left: 90px\">TotalHours&nbsp;&nbsp;&nbsp; : 6.89834875455556<\/p>\n<p style=\"padding-left: 90px\">TotalMinutes&nbsp;&nbsp; : 413.900925273333<\/p>\n<p style=\"padding-left: 90px\">TotalSeconds&nbsp;&nbsp; : 24834.0555164<\/p>\n<p style=\"padding-left: 90px\">TotalMilliseconds : 24834055.5164<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\"\" border=\"0\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use Windows PowerShell to show easily how long a process runs. &nbsp;You need to find how long a particular process has been running. How can you easily do this with Windows PowerShell? &nbsp;Use the New-TimeSpan cmdlet and specify the &ndash;Start parameter as the results from Get-Process on a process and the StartTime property. This [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[356,3,45],"class_list":["post-4096","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Use Windows PowerShell to show easily how long a process runs. &nbsp;You need to find how long a particular process has been running. How can you easily do this with Windows PowerShell? &nbsp;Use the New-TimeSpan cmdlet and specify the &ndash;Start parameter as the results from Get-Process on a process and the StartTime property. This [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=4096"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4096\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=4096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}