{"id":3564,"date":"2018-08-14T23:38:36","date_gmt":"2018-08-14T23:38:36","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=3564"},"modified":"2022-12-02T02:31:53","modified_gmt":"2022-12-02T02:31:53","slug":"how-to-search-for-services-and-scheduled-tasks-run-as-specific-user","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user","title":{"rendered":"How to search for Services and Scheduled Tasks run as specific user"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in servers.txt and come back with any results with the username you search<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n<div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">#run this script as administrator<br\/>#create a servers.txt for all the servers you want to query<br\/>$Servers = Get-Content servers.txt<br\/>#add * infront and behind username for wildcard<br\/>$user = &quot;*administrator*&quot;<br\/><br\/>$findings = foreach ($computername in $Servers){<br\/><br\/>    $schtask = schtasks.exe \/query \/s $computername \/V \/FO CSV | ConvertFrom-Csv | Where { $_.&quot;Run As User&quot; -like $user} | Select TaskName<br\/>    if ($schtask) {Write-Host &quot;`nTask&quot; + $computername + $schtask }<br\/>   <br\/>    $displayname = Get-WmiObject -class win32_service -computername $computername |where-object startname -like $user | Select displayname<br\/>    if ($displayname){Write-Host &quot;`nService&quot; + $computername + $displayname }<br\/>   <br\/>}<\/code><\/pre> <div class=\"code-embed-infos\"> <a href=\"https:\/\/github.com\/pariswells\/pariswells.com\/blob\/master\/searchServicesandTasksforUser.ps1\" title=\"See searchServicesandTasksforUser.ps1\" target=\"_blank\" class=\"code-embed-name\">searchServicesandTasksforUser.ps1<\/a> <a href=\"https:\/\/raw.github.com\/pariswells\/pariswells.com\/master\/searchServicesandTasksforUser.ps1\" title=\"Back to searchServicesandTasksforUser.ps1\" class=\"code-embed-raw\" target=\"_blank\">view raw<\/a> <\/div> <\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.pdq.com\/blog\/finding-windows-services-running-under-certain-accounts\/\">There\u2019s a free tool with PDQ Inventory for Services<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[2629,2628,2626,2625,576,2627,2624,2623,2492],"class_list":["post-3564","post","type-post","status-publish","format-standard","hentry","category-code","tag-find-all-scheduled-tasks-running-under-account","tag-find-all-services-running-under-account","tag-find-users","tag-log-on-type","tag-powershell","tag-query-all-servers","tag-scheduled-tasks","tag-services","tag-windows"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.8 - aioseo.com -->\n\t<meta name=\"description\" content=\"All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in servers.txt and come back with any results with the username you search There\u2019s a free tool with PDQ Inventory for Services\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"paris\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.8\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Welcome to Pariswells.com |\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"How to search for Services and Scheduled Tasks run as specific user | Welcome to Pariswells.com\" \/>\n\t\t<meta property=\"og:description\" content=\"All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in servers.txt and come back with any results with the username you search There\u2019s a free tool with PDQ Inventory for Services\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2018-08-14T23:38:36+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2022-12-02T02:31:53+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"How to search for Services and Scheduled Tasks run as specific user | Welcome to Pariswells.com\" \/>\n\t\t<meta name=\"twitter:description\" content=\"All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in servers.txt and come back with any results with the username you search There\u2019s a free tool with PDQ Inventory for Services\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#article\",\"name\":\"How to search for Services and Scheduled Tasks run as specific user | Welcome to Pariswells.com\",\"headline\":\"How to search for Services and Scheduled Tasks run as specific user\",\"author\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#organization\"},\"datePublished\":\"2018-08-14T23:38:36+00:00\",\"dateModified\":\"2022-12-02T02:31:53+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#webpage\"},\"articleSection\":\"Code, find all scheduled tasks running under account, find all services running under account, find users, log on type, powershell, query all servers, Scheduled Tasks, Services, windows\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/pariswells.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/category\\\/code#listItem\",\"name\":\"Code\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/category\\\/code#listItem\",\"position\":2,\"name\":\"Code\",\"item\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/category\\\/code\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#listItem\",\"name\":\"How to search for Services and Scheduled Tasks run as specific user\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#listItem\",\"position\":3,\"name\":\"How to search for Services and Scheduled Tasks run as specific user\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/category\\\/code#listItem\",\"name\":\"Code\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#organization\",\"name\":\"Welcome to Pariswells.com\",\"url\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris#author\",\"url\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris\",\"name\":\"paris\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/93b8ee3f592ac401167f870452bd82d43de80152cd3524e2853403658ada9984?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"paris\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#webpage\",\"url\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user\",\"name\":\"How to search for Services and Scheduled Tasks run as specific user | Welcome to Pariswells.com\",\"description\":\"All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in servers.txt and come back with any results with the username you search There\\u2019s a free tool with PDQ Inventory for Services\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/code\\\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris#author\"},\"datePublished\":\"2018-08-14T23:38:36+00:00\",\"dateModified\":\"2022-12-02T02:31:53+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/\",\"name\":\"Welcome to Pariswells.com\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How to search for Services and Scheduled Tasks run as specific user | Welcome to Pariswells.com","description":"All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in servers.txt and come back with any results with the username you search There\u2019s a free tool with PDQ Inventory for Services","canonical_url":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#article","name":"How to search for Services and Scheduled Tasks run as specific user | Welcome to Pariswells.com","headline":"How to search for Services and Scheduled Tasks run as specific user","author":{"@id":"https:\/\/pariswells.com\/blog\/author\/paris#author"},"publisher":{"@id":"https:\/\/pariswells.com\/blog\/#organization"},"datePublished":"2018-08-14T23:38:36+00:00","dateModified":"2022-12-02T02:31:53+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#webpage"},"isPartOf":{"@id":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#webpage"},"articleSection":"Code, find all scheduled tasks running under account, find all services running under account, find users, log on type, powershell, query all servers, Scheduled Tasks, Services, windows"},{"@type":"BreadcrumbList","@id":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/pariswells.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/category\/code#listItem","name":"Code"}},{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/category\/code#listItem","position":2,"name":"Code","item":"https:\/\/pariswells.com\/blog\/category\/code","nextItem":{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#listItem","name":"How to search for Services and Scheduled Tasks run as specific user"},"previousItem":{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#listItem","position":3,"name":"How to search for Services and Scheduled Tasks run as specific user","previousItem":{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/category\/code#listItem","name":"Code"}}]},{"@type":"Organization","@id":"https:\/\/pariswells.com\/blog\/#organization","name":"Welcome to Pariswells.com","url":"https:\/\/pariswells.com\/blog\/"},{"@type":"Person","@id":"https:\/\/pariswells.com\/blog\/author\/paris#author","url":"https:\/\/pariswells.com\/blog\/author\/paris","name":"paris","image":{"@type":"ImageObject","@id":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/93b8ee3f592ac401167f870452bd82d43de80152cd3524e2853403658ada9984?s=96&d=mm&r=g","width":96,"height":96,"caption":"paris"}},{"@type":"WebPage","@id":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#webpage","url":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user","name":"How to search for Services and Scheduled Tasks run as specific user | Welcome to Pariswells.com","description":"All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in servers.txt and come back with any results with the username you search There\u2019s a free tool with PDQ Inventory for Services","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/pariswells.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user#breadcrumblist"},"author":{"@id":"https:\/\/pariswells.com\/blog\/author\/paris#author"},"creator":{"@id":"https:\/\/pariswells.com\/blog\/author\/paris#author"},"datePublished":"2018-08-14T23:38:36+00:00","dateModified":"2022-12-02T02:31:53+00:00"},{"@type":"WebSite","@id":"https:\/\/pariswells.com\/blog\/#website","url":"https:\/\/pariswells.com\/blog\/","name":"Welcome to Pariswells.com","inLanguage":"en-US","publisher":{"@id":"https:\/\/pariswells.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Welcome to Pariswells.com |","og:type":"article","og:title":"How to search for Services and Scheduled Tasks run as specific user | Welcome to Pariswells.com","og:description":"All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in servers.txt and come back with any results with the username you search There\u2019s a free tool with PDQ Inventory for Services","og:url":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user","article:published_time":"2018-08-14T23:38:36+00:00","article:modified_time":"2022-12-02T02:31:53+00:00","twitter:card":"summary","twitter:title":"How to search for Services and Scheduled Tasks run as specific user | Welcome to Pariswells.com","twitter:description":"All organizations should be using service accounts for Specific Tasks and Services, however, some legacy systems might not be. This script will search all servers listed in servers.txt and come back with any results with the username you search There\u2019s a free tool with PDQ Inventory for Services"},"aioseo_meta_data":{"post_id":"3564","title":null,"description":null,"keywords":[],"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-21 05:34:09","updated":"2022-12-02 02:46:44","primary_term":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/pariswells.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/pariswells.com\/blog\/category\/code\" title=\"Code\">Code<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to search for Services and Scheduled Tasks run as specific user\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/pariswells.com\/blog"},{"label":"Code","link":"https:\/\/pariswells.com\/blog\/category\/code"},{"label":"How to search for Services and Scheduled Tasks run as specific user","link":"https:\/\/pariswells.com\/blog\/code\/how-to-search-for-services-and-scheduled-tasks-run-as-specific-user"}],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=3564"}],"version-history":[{"count":3,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3564\/revisions"}],"predecessor-version":[{"id":6447,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3564\/revisions\/6447"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=3564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=3564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=3564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}