{"id":515,"date":"2009-11-19T12:43:38","date_gmt":"2009-11-19T17:43:38","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=515"},"modified":"2012-12-27T17:01:48","modified_gmt":"2012-12-27T22:01:48","slug":"find-that-service","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/","title":{"rendered":"Find That Service"},"content":{"rendered":"<p>Once again, the fine forum members at <a href=\"http:\/\/www.scriptinganswers.com\/\" target=\"_blank\">ScriptingAnswers.com<\/a> come through and help get my PowerShell idea engine revving. The latest post posed this basic question: \u201cI need to query my servers and find all services using a specific service account.\u201d The poster thought this would be a good opportunity to learn PowerShell and I wholeheartedly agree.\u00a0 Here\u2019s my approach.<!--more--><\/p>\n<p>First off, the <a title=\"get online help\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113332\" target=\"_blank\">Get-Service<\/a> cmdlet can\u2019t help, even though in PowerShell v2 it can connect to remote computers. The problem is that the .NET service object which the cmdlet uses knows nothing about the startup account. But WMI does.<\/p>\n<p>If you query a service using WMI, there is a property called StartName. Normally this will be something like LocalSystem. But sometimes you need to use a custom domain account. That\u2019s what the question is all about. I\u2019ll use LocalSystem as the accountname for demonstration purposes. Using <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd315295.aspx\" target=\"_blank\">Get-WMIObject<\/a> we can filter for the account.<\/p>\n<div id=\"codeSnippetWrapper\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 10pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;\">\n<div id=\"codeSnippet\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">PS C:\\&gt; get-wmiobject win32_service -filter \"startname='localsystem'\" | Select Displayname<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">Displayname<\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">\r\n-----------<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">Active Directory Web Services<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">Application Experience Lookup Service<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">Application Management<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">Windows Audio<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">Background Intelligent Transfer Service<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">Computer Browser<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">...<\/pre>\n<p><!--CRLF--><\/p>\n<\/div>\n<\/div>\n<p>Obviously I\u2019ve truncated the output. Running through a list of servers to find the appropriate services isn\u2019t much more difficult. I\u2019ll put the list of servers to query in a text file and have a pretty simple PowerShell one-liner.<\/p>\n<div id=\"codeSnippetWrapper\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 10pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;\">\n<div id=\"codeSnippet\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">PS C:\\&gt; get-wmiobject win32_service -filter \"startname='LocalSystem'\" -computer (get-content computers.txt) | Select SystemName,Name,Displayname,State,StartMode<\/pre>\n<\/div>\n<\/div>\n<p>Of course if you want other service properties you can add them. You could sort or filter further. My original suggestion was to export the output to a csv file.<\/p>\n<div id=\"codeSnippetWrapper\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 10pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;\">\n<div id=\"codeSnippet\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 10pt; overflow: visible; border-style: none; padding: 0px;\">PS C:\\&gt; get-wmiobject win32_service -filter \"startname='LocalSystem'\" -computer (get-content computers.txt) | Select SystemName,Name,Displayname,State,StartMode | Export-CSV servicereport.csv<\/pre>\n<p><!--CRLF--><\/p>\n<\/div>\n<\/div>\n<p>That way he could open the CSV file in Excel and massage the data anyway he liked. Although you could do a lot of it in PowerShell as well. But also by saving the output to a file, he can use it later when it comes time to changing the password for all those services.<\/p>\n<p>I love examples like this. In VBScript, to go through a list of servers, use WMI to get the service information and save the ouput to a CSV file would easily be a 10-15 line script. Plus you\u2019d have to create the script file, save it and then run it. Compared to typing a one-line PowerShell expression which takes a fraction of the time to develop. Which would you rather do?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Once again, the fine forum members at ScriptingAnswers.com come through and help get my PowerShell idea engine revving. The latest post posed this basic question: \u201cI need to query my servers and find all services using a specific service account.\u201d The poster thought this would be a good opportunity to learn PowerShell and I wholeheartedly&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[72,4,8],"tags":[534,141,547],"class_list":["post-515","post","type-post","status-publish","format-standard","hentry","category-commandline","category-powershell","category-scripting","tag-powershell","tag-services","tag-wmi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Find That Service &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Find That Service &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Once again, the fine forum members at ScriptingAnswers.com come through and help get my PowerShell idea engine revving. The latest post posed this basic question: \u201cI need to query my servers and find all services using a specific service account.\u201d The poster thought this would be a good opportunity to learn PowerShell and I wholeheartedly...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2009-11-19T17:43:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-12-27T22:01:48+00:00\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/515\\\/find-that-service\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/515\\\/find-that-service\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Find That Service\",\"datePublished\":\"2009-11-19T17:43:38+00:00\",\"dateModified\":\"2012-12-27T22:01:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/515\\\/find-that-service\\\/\"},\"wordCount\":359,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"PowerShell\",\"services\",\"WMI\"],\"articleSection\":[\"CommandLine\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/515\\\/find-that-service\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/515\\\/find-that-service\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/515\\\/find-that-service\\\/\",\"name\":\"Find That Service &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2009-11-19T17:43:38+00:00\",\"dateModified\":\"2012-12-27T22:01:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/515\\\/find-that-service\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/515\\\/find-that-service\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/515\\\/find-that-service\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"CommandLine\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/commandline\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Find That Service\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Find That Service &#8226; The Lonely Administrator","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:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/","og_locale":"en_US","og_type":"article","og_title":"Find That Service &#8226; The Lonely Administrator","og_description":"Once again, the fine forum members at ScriptingAnswers.com come through and help get my PowerShell idea engine revving. The latest post posed this basic question: \u201cI need to query my servers and find all services using a specific service account.\u201d The poster thought this would be a good opportunity to learn PowerShell and I wholeheartedly...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/","og_site_name":"The Lonely Administrator","article_published_time":"2009-11-19T17:43:38+00:00","article_modified_time":"2012-12-27T22:01:48+00:00","author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Find That Service","datePublished":"2009-11-19T17:43:38+00:00","dateModified":"2012-12-27T22:01:48+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/"},"wordCount":359,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["PowerShell","services","WMI"],"articleSection":["CommandLine","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/","name":"Find That Service &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2009-11-19T17:43:38+00:00","dateModified":"2012-12-27T22:01:48+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/515\/find-that-service\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"CommandLine","item":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},{"@type":"ListItem","position":2,"name":"Find That Service"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1551,"url":"https:\/\/jdhitsolutions.com\/blog\/wmi\/1551\/find-non-system-service-accounts-with-powershell-and-wmi\/","url_meta":{"origin":515,"position":0},"title":"Find Non System Service Accounts with PowerShell and WMI","author":"Jeffery Hicks","date":"July 5, 2011","format":false,"excerpt":"As easy as Get-Service is to use in PowerShell, it has one limitation for IT Pros: it can't show you what account the service is running under. In old school terms, \"What is the service account?\" Fortunately you can get that information using WMI. Here's a query you can use\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":100,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/100\/more-with-service-uptime\/","url_meta":{"origin":515,"position":1},"title":"More with Service Uptime","author":"Jeffery Hicks","date":"February 16, 2007","format":false,"excerpt":"I knew I wasn't totally satisfied with my recent attempt at listing service uptime. I knew there was a more elegant solution and here it is: $s=Get-WmiObject -query \"Select name,processId,state from Win32_service where state='running'\"foreach ($item in $s) {$p=(Get-Process | Where {$_.id -eq $item.ProcessID}).StartTime$u=(get-date).Subtract($p)Write-Host $item.Name `t $u.Days day $u.hours hours $u.minutes\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3497,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3497\/resolving-sids-with-wmi-wsman-and-powershell\/","url_meta":{"origin":515,"position":2},"title":"Resolving SIDs with WMI, WSMAN and PowerShell","author":"Jeffery Hicks","date":"October 15, 2013","format":false,"excerpt":"In the world of Windows, an account SID can be a very enigmatic thing. Who is S-1-5-21-2250542124-3280448597-2353175939-1019? Fortunately, many applications, such as the event log viewer resolve the SID to an account name. The downside, is that when you are accessing that same type of information from PowerShell, you end\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"win32_sid-fail","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/10\/win32_sid-fail-1024x330.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/10\/win32_sid-fail-1024x330.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/10\/win32_sid-fail-1024x330.png?resize=525%2C300 1.5x"},"classes":[]},{"id":103,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/103\/more-with-process-and-service-uptime\/","url_meta":{"origin":515,"position":3},"title":"More with Process and Service uptime","author":"Jeffery Hicks","date":"February 20, 2007","format":false,"excerpt":"Like most things scripting, there's usually more than one way to do things. I thought I had a nice solution for getting service uptime via WMI. But alas, there is an even easier way. PowerShell has a ConvertToDateTime method which will convert a WMI time to a standard date time\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":37,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/37\/get-active-directory-user-information-in-powershell\/","url_meta":{"origin":515,"position":4},"title":"Get Active Directory User Information in PowerShell","author":"Jeffery Hicks","date":"July 5, 2006","format":false,"excerpt":"One feature that PowerShell will likely be missing when it first ships is solid support for ADSI and working with Active Directory. You can use .NET DirectoryEntry objects but it feels more like programming and less like scripting. Another option for working with Active Directory in PowerShell is to use\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1201,"url":"https:\/\/jdhitsolutions.com\/blog\/wmi\/1201\/new-event-report-revised\/","url_meta":{"origin":515,"position":5},"title":"New Event Report Revised","author":"Jeffery Hicks","date":"March 8, 2011","format":false,"excerpt":"Last year I posted an update to an old Mr. Roboto script that was an update to an even older VBScript. Still with me? My last revision leveraged the new Get-WinEvent cmdlet to create an HTML report of recent error activity on one or more computers. The problem was that\u2026","rel":"","context":"In &quot;Mr. Roboto&quot;","block_context":{"text":"Mr. Roboto","link":"https:\/\/jdhitsolutions.com\/blog\/category\/mr-roboto\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=515"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/515\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}