{"id":4449,"date":"2012-12-19T11:59:00","date_gmt":"2012-12-19T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/12\/19\/powertip-search-for-inactive-user-accounts-in-windows-server-2012-active-directory\/"},"modified":"2012-12-19T11:59:00","modified_gmt":"2012-12-19T11:59:00","slug":"powertip-search-for-inactive-user-accounts-in-windows-server-2012-active-directory","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-search-for-inactive-user-accounts-in-windows-server-2012-active-directory\/","title":{"rendered":"PowerTip: Search for Inactive User Accounts in Windows Server 2012 Active Directory"},"content":{"rendered":"<p><strong>Summary:<\/strong>&nbsp;Learn how to use Windows PowerShell to search for inactive user accounts in Active Directory for Windows Server&nbsp;2012.<\/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;How can I query inactive user accounts in my Windows Server&nbsp;2012 Active Directory environment?<\/p>\n<p style=\"padding-left: 60px\"><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;Charlotte Windows PowerShell user group member Brian Wilhite says: You can use the ActiveDirectory module that contains the&nbsp;<strong>Search-ADAccount<\/strong>&nbsp;cmdlet used to query inactive user and computer accounts. For user accounts only, you&rsquo;ll use the&nbsp;<strong>UsersOnly<\/strong>&nbsp;parameter.<\/p>\n<p style=\"padding-left: 90px\">Search-ADAccount -AccountInactive -UsersOnly<\/p>\n<p style=\"padding-left: 60px\">You can also use the&nbsp;<strong>TimeSpan<\/strong>&nbsp;parameter to specify account inactivity. the example below specifies 30 days of inactivity.<\/p>\n<p style=\"padding-left: 90px\">Search-ADAccount -AccountInactive -UsersOnly -TimeSpan 30.00:00:00<\/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:&nbsp;Learn how to use Windows PowerShell to search for inactive user accounts in Active Directory for Windows Server&nbsp;2012. &nbsp;How can I query inactive user accounts in my Windows Server&nbsp;2012 Active Directory environment? &nbsp;Charlotte Windows PowerShell user group member Brian Wilhite says: You can use the ActiveDirectory module that contains the&nbsp;Search-ADAccount&nbsp;cmdlet used to query inactive user [&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":[327,56,356,3,45],"class_list":["post-4449","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-brian-wilhite","tag-guest-blogger","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary:&nbsp;Learn how to use Windows PowerShell to search for inactive user accounts in Active Directory for Windows Server&nbsp;2012. &nbsp;How can I query inactive user accounts in my Windows Server&nbsp;2012 Active Directory environment? &nbsp;Charlotte Windows PowerShell user group member Brian Wilhite says: You can use the ActiveDirectory module that contains the&nbsp;Search-ADAccount&nbsp;cmdlet used to query inactive user [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4449","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=4449"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4449\/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=4449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}